Install Laravel on Mac and Windows OS

Install Laravel on Mac and Windows OS

    We will see how to use Laravel in Mac

    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 key:generate
     
    Try to access the backend now and see
     
    Solution 2 cache clear
    Try to run the below command from root folder of your project.
    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

    Make sure inside public folder you have .htaccess file. If not create one
    <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.

    1. It is located in the file to grant the permission "c:/xampp/php/php.ini". And for your case its - C:\MAMP\bin\php\php7.4.1\php.ini
    2. Right click on the file and click on properties.
    3. Security.
    4. Click on the Edit button.
    5. Click on each of the group or user names and at the bottom where it says Permissions for authenticated users, and then check full control.

    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.

    Courses


    Recent posts