The following tutorial column of composer will explain in detail the process of creating a new laravel project with composer. I hope it will be helpful to friends in need!
For a long time, PHP’s open source method has been project-level, which means that as soon as I open source it is a project , such as a set of CMS, a framework such as Codeigniter. why? One of the important reasons is that it is difficult to take them apart. If they are taken apart, there is no effective management tool to combine them, resulting in no one paying attention to the small modules that have been taken apart.
Then Composer appeared. It is responsible for managing the various small modules that everyone has open source, and effectively integrating them together to make them a complete project.
composer is one of the PHP code dependency management tools
For example, if your project needs to use the PHPmail class library, as long as you follow the composer format, composer
can automatically help you download this code library. In your project.
First, use Composer to download the Laravel installer:
composer global require "laravel/installer"
Install laravel
composer create-project --prefer-dist laravel/laravel blog
View laravel version
laravel -v
cd /data/www/
composer create-project --prefer-dist laravel/laravel blog
This line The command will create a project called blog. ps: This line of code has been run once. Running it again will cause the terminal to get stuck and nothing will be displayed.
Enter the project directory
subl .
composer.json describes the dependencies of this project
In "require" Seeing that this project uses the laravel framework 5.5
and then relying on it layer by layer
describes the main reliance on mpm dependency package
For example
axios is used to initiate front-end business requests
cross-env webpack command
Note: bootstrap is configured with sass source code (/resources/assets/sass/app.scss) by default
sudo apt install npm
npm i
After the installation is complete, you can see that the packages that the front-end depends on are placed in the newly generated node_modules directory
First configure the hosts file (hosts file location: /etc /hosts)
127.0.1.1 l.blog.com
Enter l.blog.com in the browser
sudo nginx -t
subl nginx directory address
The nginx configuration file is the entrance to nginx. It configures the basic configuration of http and the configuration of the site. The configuration can be referenced
You need to configure the server in nginx to access the website For example, when setting server_name *.blog.com, when we enter l.blog.com, it will automatically match the server, and then go to the /data/www/blog.com/public directory under the root to find the PHP default page, which is index .php was looking for execution, so we changed it to the laravel framework, and our website can be accessed.
There are two very important files here, enable-php.conf and enable-laravel.conf
enable-php.conf is responsible for configuring communication with php
enable-laravel.conf is handwritten and can Query in the laravel documentation how to make the website a laravel-compliant document
location / {
try_files`$uri`$uri/`/ index.php$is_args$args;
}
A: Indicates that the laravel framework has been entered Category
Change folder permissions sudo chmod -R 777. Note: R is capitalized here
A: Press F12 to check the website. The network found that one time has been in the pending state, and other tasks have been completed.
When the cursor moves up, it shows fonts.googleapis.com
which has been referenced in views. For Google fonts, find welcome.blade.php
in the views directory. Comment out the raleway font here and it will be ok
Second, the Google fonts referenced by bootstrap cause circles
Find /resources/assets/ sass/app.scss
I found that bootstrap uses the font library of Raleway by default, which is from Google. Just comment it out and it will be ok
Note: What is modified here is the sass source code and needs to be recompiled
npm run prod
A: This is because the nginx.conf file is not configured Good
subl /usr/local/nginx/conf/nginx.conf
Reconfigure a server ps: It is best to put all projects in one directory to develop good habits. The project path is easy to write here.
After configuring the server, check the configuration file
sudo nginx -s reload
sudo nginx -t
After the check is correct, you can access the project
The above is the detailed content of Detailed explanation of composer's process of creating a new laravel project. For more information, please follow other related articles on the PHP Chinese website!