Home  >  Article  >  PHP Framework  >  Installation and configuration of Laravel in MAC environment

Installation and configuration of Laravel in MAC environment

演明
演明Original
2021-08-25 07:49:022122browse

I encountered many small problems when installing laravel in a Mac environment. Below I have compiled my notes during the installation process. Hope this can provide support for developers who encounter problems.

Related recommendations:                                  
1. "Environmental installation of apache, php, postgresql for windows server" ​
2.《MAC environment installation of php, apache, MacPorts and other environment configurations
3.《MAC environment installation of node, vue and other environment configurations

1. Install the necessary software

First, install Mac firstComposer

(1) Execute on the command line:

$curl -sS https://getcomposer.org/installer | php

(2) If curl is not installed, execute the following code:

$php -r "readfile('https://getcomposer.org/installer');" | php

(3) Execute (available globally):

$sudo mv composer.phar /usr/local/bin/composer

(4) Modify composer permissions:

$sudo chmod a+x /usr/local/bin/composer

(5) Check whether composer is installed successfully. Execute the following command. The following image will be displayed to indicate successful installation.

$ composer -v

2. Install laravel

1. Command installation: Enter the file path

$sudo composer create-project --prefer-dist laravel/Laravel laravelapp    #laravelapp是我的项目名

2. Download the one-click installation package on git (https ://github.com/laravel/laravel/tree/master)

Unzip and place it in the corresponding path. The project name is (laravel). Note that the one-click installation package downloaded from git does not have the vendor folder content ( autoload.php), needs to be executed in the project path (that is, in the same directory as the public folder under the laravel folder)

$sudo composer install

3. The running environment reports an error (it is best to enter the directory for normal one-click installation packages Execute the following command to regenerate the application APP_KEY)

$sudo php artisan key:generate

If prompted [ErrorException]

file_get_contents(D:\Apache24\htdocs\laravel/.env): failed to open stream: No such file or directory

4. There is an .env.example in the root directory file (hidden file), copy the .env.example file and rename it to the .env file and execute the command again

$sudo php artisan key:generate

The following display indicates that laravel is installed successfully

Application key [base64:Dmr3sXelvMj1GYiv9UGGzUay25UTIrOyo2VwqW2RNDE=] set successfully.

Note:

Do not try to submit the .env file to a version control system (such as Git or Svn). On the one hand, the development environment and line The environment configuration values ​​are different, so submitting is meaningless. More importantly, .env contains a lot of application-sensitive information, such as database usernames and passwords. If you accidentally submit the code to the Github public repository, the consequences will be disastrous!

You can also create a .env.testing file, which will be used when running PHPUnit tests or executing with --env=testing option of the Artisan command when overriding the value read from the .env file.

The above steps have been installed successfully by me. Just follow the steps above to install them step by step. If you don’t understand anything, please leave a message. Thank you for your support. Hope this helps everyone.

Related recommendations: The latest five Laravel video tutorials

The above is the detailed content of Installation and configuration of Laravel in MAC environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn