Home>Article>Development Tools> Class library manager composer installs and configures laravel

Class library manager composer installs and configures laravel

演明
演明 Original
2021-09-10 20:50:37 1569browse

When doing projects using the laravel framework, sometimes my mind goes blank and I don’t know how to start, or I encounter many small problems when installing laravel and I don’t know how to solve them. Below I have compiled the notes during the installation process. Hope this can provide support for developers who encounter problems.

1. Download and installation of composer

composerDownload

English website: https://getcomposer.org/

Chinese image: http://www.phpcomposer.com/

1. Tutorial on installing composer under windows:

Chinese image

Class library manager composer installs and configures laravel

Class library manager composer installs and configures laravel

Class library manager composer installs and configures laravel

No need to modify this configuration

Class library manager composer installs and configures laravel

You need to pay attention here before installing this composer A PHP environment is required

Class library manager composer installs and configures laravel

#The above step can be directly installed. After completion, use the composer -v of the cmd command to detect it.

2. Tutorial on installing composer under mac system:

Download Composer directly in command line mode under mac

Use curl command to download:

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

Or if curl is not installed, you can also use the php command to download:

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

Manually download Composer

Address: https://getcomposer.org/composer.phar

After you download composer.phar, you can place it in the directory, but every time you create a new directory, you must make a copy to the new directory, which is more troublesome. So the best way is to put it in usr/local/bin and make it a global command.

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

This way you can use the composer command directly in the terminal

2. Laravel installation

composer installs Laravel

1. Download and install directly (need to bypass the wall)

Create a Laravel project named laravel

composer create-project laravel/laravel --prefer-dist

Create a Laravel project named blog

composer create-project laravel/laravel blog -prefer-dist

2. Use the composer image to install (do not circumvent the wall)

Use the Composer image to install the latest version of Laravel

There are two ways to enable the mirror service:

System global configuration: add the configuration information to composer's global configuration file config.json,

Individual project configuration: add the configuration information to a certain In the composer.json file of each project

Example 1: Modify the global configuration file of composer (recommended method)

Open the command line window (windows users) or console (Linux. Mac users) And execute the following command:

composer config -g repo.packagist composer https://packagist.phpcomposer. com

After the execution of the above command is completed, you can execute the following command again without going over the wall.

Create a Laravel project named laravel

composer create-project laravel/laravel --prefer-dist

Create a Laravel project named blog

composer create-project laravel/laravel blog -prefer-dist

Example 2: Modify the composer.json configuration file of the current project:

Open the command line window (windows users) or console (Linux, Mac users ), enter the root directory of your project (that is, all directories of the composer.json file), and execute the following command:

composer config repo.packagist composer nttps://packagist. phpcoeposer. com

Step 1: Because it is executed under the current project, create a project file first Folder test

Class library manager composer installs and configures laravel

The second step is to modify the composer file of the current project, so there must be a composer.json file first, so manually simulate a text file without any settings. , just name it composer.json.

Class library manager composer installs and configures laravel

Class library manager composer installs and configures laravelAs prompted above, click "Yes"

Class library manager composer installs and configures laravel

Then execute the following command:

composer config repo.packagist composer nttps://packagist. phpcoeposer. com

Class library manager composer installs and configures laravel

Take a look at the composer.json file. This is a file with some extra content.

Class library manager composer installs and configures laravel

Then you can use the following command without going over the wall. .

Create a Laravel project named laravel

composer create-project laravel/laravel --prefer-dist

Create a Laravel project named blog

composer create-project laravel/laravel blog -prefer-dist

The above command will be in the composer.json file in the current project The configuration information of the mirror is automatically added at the end (you can also add it manually): The content in the

composer.json file (as shown in the screenshot above) means that the installation of laravel is specified as the Chinese website URL.

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.

The above is the detailed content of Class library manager composer installs and configures laravel. 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