We will see how to use or install Laravel in Mac. This approach is also valid for M1 chip Mac book.
There are four steps to do it.
1. Install Homebrew
2. Install PHP
3. Install Composer
4. Install Laravel
Install Homebrew
Run the below command to install. It's a mac installation package manager.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install PHP
Then we will install PHP using brew
brew install php
Install Composer
And then install composer using brew
brew install composer
Install Laravel
And then intsall laravel using composer
composer create-project laravel/laravel example-app
After that you do run the following command to start laravel
php artisan key:generate
php artisan serve
With above installation process on Mac, you must first install homebrew. If homebrew cannot be installed for some reasons you can try the below alternatives.
Alternatives
Use the below command to install PHP. It's for PHP version 7.3 or later
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
If composer fails to download and install you can try different ways and see what works. Try the below ways to download and install composer
1. First way
Then use the below command to install composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composerphp composer-setup.php
chmod +x /usr/local/bin/composer
sudo composer self-update
2. Second way
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
A lot of time laravel fails to download because the server request timed out. That happens because your internet speed or connect. In that case you need to set compser
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
With the above command I am telling composer to download laravel from aliyun mirror.
And the use the below command to install Laravel
composer create-project laravel/laravel example-app
php artisan key:generate
php artisan serve
Install Laravel video tutorial
Laravel Windows Installation
Install Laravel Backend on Mac
Install Laravel Backend on Windows
Access error
If you can not access backend with /admin try the below solutions
Solution 1 update composer
composer update
copy env.example .env
php artisan cache:clear
php artisan config:clear;
php artisan optimize;
Try to access the backend now and see
Solution 3 .env file
Also try the below solution. Change the .env file. If you did not have SSL installed, then do the below settings in your .env file
FORCE_HTTPS = false
ADMIN_HTTPS = false
Try to access the backend now and see
Solution 4 .htaccess file
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Also try
Package problem
Your requirements could not be resolved to an installable set of packages
You need to uncomment the extension "extension = fileinfo" in the php.ini file from the source folder. Then delete projectx dir. Finally, re-run laravel new projectx as per your screenshot.
If you have already uncomment "extension = fileinfo" in php.ini and it doesn't work. You might need to grant administrator permissions to be able to execute the changes:
To grant these permissions you have to do the following: Note: This for windows 10.
In this way permission is granted and now if the changes to the file are saved.
Windows 10 Firewall problem
Windows 10 firewall could cause a problem from localhost if you try to install the backend locally. Watch the youtube video from the link below and see if the firewall is causing problem or not.
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
2024-07-11 18:15:25
same problem cant access the backend.admin error:The information you’re about to submit is not secure Because this form is being submitted using a connection that’s not secure, your information will be visible to others. credential not match
You can access it anyway, it's safe. It may show you unsafe. But it's fine.
2024-07-10 11:17:33
sir i cant access to the backend /admin
what error do you see?