Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Composer's method of creating a New laravel Project

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of composer to create a new laravel project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand it.

What is Composer

For a long time, PHP's open source approach is project-level, that is, I open source is a project, such as a complete set of CMS, a framework, such as Codeigniter. Why is that? One of the very important reasons is that it is difficult for you to take it apart. If you take it apart, there is not an effective management tool to combine. As a result, no one cares about the small module that is taken apart.

Then Composer appeared, which is responsible for managing all the small open source modules and effectively integrating them together to make it a complete project.

Composer is one of the PHP code dependency management tools.

For example, your project needs to use the PHPmail class library, as long as according to the composer format, composer

It will automatically help you pull down this code base into your project.

Second, install laravel

First, download the Laravel installer using Composer:

Composer global require "laravel/installer"

Install laravel

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

View laravel version

Laravel-v

Third, create a new project. Enter the directory

Cd / data/www/

two。 Create a new project

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

This command creates a project called blog. Ps: you have already run this line of code once, and running it again will cause terminal to get stuck and nothing will be displayed.

3. View the project catalog

Enter the project directory

Subl.

4. The backend pays attention to the composer.json file (located directly in the blog directory)

Composer.json describes what dependencies the project has

In "require", you can see that this project uses the laravel framework 5.5.

And then rely on it layer by layer.

5. The front end pays attention to package.json

Describes the dependency packages that rely mainly on mpm

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.

6. Install nmp

Sudo apt install npm

Npm i

After the installation is complete, you can see that the front-end dependent packages are placed in the newly generated node_modules directory

7. After the project is created, you can see that the .env file has been generated. Browsers view local web pages

First configure the hosts file (hosts file location: / etc/hosts)

127.0.1.1 l.blog.com

Browser input l.blog.com

9. View nginx configuration (nginx is not responsible for parsing php)

Sudo nginx-t

Subl nginx directory address

The nginx configuration file is the portal to nginx to configure the basic configuration of http and the configuration of the site, which can be referenced

You need to configure server in nginx to access the website. For example, set server_name * .blog.com to automatically match to server when we enter l.blog.com, and then go to the root / data/www/blog.com/public directory to find the default page of php, that is, index.php to find and execute, so switch to the laravel framework, and our website can be accessed.

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 be found in laravel documents to find out how to make a website laravel compliant

Location / {

Try_ files` $uri` $uri/ `/ index.php$is_args$args

}

IV. Qyoga

q. UnexpectedValueException:the stream or file "/ data/www/blog.com/storage/logs/laravel.log" could not be open:failed to open stream:Permission denied appears

A: it indicates that it has entered the scope of the laravel framework.

Change folder permissions sudo chmod-R 777. Note: r uppercase here

q. Keep turning around when loading the website.

A: press F12 to check the website, network found that one time has been in the pending state, other tasks have been completed

Move the cursor up to show fonts.googleapis.com

Google fonts have been quoted on views to find the welcome.blade.php in the views directory.

Comment out the raleway font here and ok it.

Second, Google fonts quoted by bootstrap cause circles

Find / resources/assets/sass/app.scss

Find that bootstrap is using raleway font library by default, which is Google's thing. Comment it out and ok it.

Note: the sass source code is modified here and needs to be recompiled

Npm run prod

q. The LNMP one-click installation package page appears after the browser enters l.blog.com

A: this is because the nginx.conf file is not configured properly

Subl / usr/local/nginx/conf/nginx.conf

Reconfigure a server ps: it's best to put your projects in one directory and form a good habit. Here the project path is easy to write.

After configuring server, check the configuration file

Sudo nginx-s reload

Sudo nginx-t

You can access the project after checking it correctly.

Thank you for reading this article carefully. I hope the article "composer's way to create a new laravel project" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report