search
HomeDevelopment ToolscomposerDetailed explanation of composer's process of creating a new laravel project

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!

Detailed explanation of composer's process of creating a new laravel project

1. What is Composer

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.

2. Install laravel

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

3. Create a new project

1. Enter the directory

cd /data/www/

2. Create a new project

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.

3. Check the project directory

Enter the project directory
subl .

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

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

5. The front-end pays attention to package.json

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

6. Install nmp

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

7. After the project is created, you can see that the .env file has been generated

8. View the local web page with the browser

First configure the hosts file (hosts file location: /etc /hosts)
127.0.1.1 l.blog.com
Enter l.blog.com in the browser

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

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;
}

4. Q&A

  • Q. unexpectedValueException: the stream or file “/data/www/blog.com/storage/logs/laravel.log”could not be open:failed to open stream:Permission denied

A: Indicates that the laravel framework has been entered Category
Change folder permissions sudo chmod -R 777. Note: R is capitalized here

  • Q. It keeps spinning when loading the website

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

  • Q. After entering l.blog.com in the browser, the LNMP one-click installation package page appears

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!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
四大步教你在Debian11上安装使用Composer!四大步教你在Debian11上安装使用Composer!Nov 08, 2022 pm 04:32 PM

本文由composer​教程栏目给大家介绍关于在Debian11上是怎么一步步安装,以及使用Composer的 ,非常详细哦~希望对需要的朋友有所帮助!

Composer是啥Composer是啥Dec 25, 2023 pm 03:06 PM

Composer是PHP的依赖管理工具,它允许开发者将第三方库和框架与自己的项目进行集成。它的主要功能包括:1、依赖管理;2、版本控制;3、自动加载;4、扩展开发;5、集成其他工具。它简化了PHP项目的依赖管理过程,确保项目的稳定性和可维护性。通过使用Composer,开发者可以更加高效地管理自己的项目和集成第三方库和框架。

composer 怎么修改php路径composer 怎么修改php路径Oct 24, 2022 am 11:33 AM

composer修改php路径的方法:1、搜索“composer.bat”并复制到项目文件夹;2、编辑“composer.bat”,将内容修改为“@ECHO OFF php "%~dp0composer.phar" %*”即可。

PHP使用Composer安装和管理依赖包PHP使用Composer安装和管理依赖包Jun 18, 2023 pm 03:30 PM

在PHP开发中,我们经常要处理各种依赖包,这些依赖包可能是其他开发者编写的PHP库文件,也可能是一些第三方工具和框架。为了方便管理这些依赖包,我们可以使用Composer来进行相关的安装和管理工作。Composer是一个开源的PHP依赖管理工具,它可以帮助我们自动化安装、更新和卸载PHP依赖包。通过Composer,我们可以轻松地管理我们应用中的不同依赖,同

使用Composer和PHP包管理器的最佳实践使用Composer和PHP包管理器的最佳实践May 23, 2023 am 08:29 AM

随着PHP的日益流行,PHP开发人员面临着许多挑战,其中包括代码管理、可重用性和依赖性管理。这些问题可以使用包管理器来解决,而Composer是PHP最受欢迎的包管理器之一。在本文中,我们将探讨使用Composer和PHP包管理器的最佳实践,从而提高您的PHP开发效率和代码质量。何为Composer?Composer是一款PHP包管理器,它可以轻松管理PHP

创建composer项目的步骤创建composer项目的步骤Feb 19, 2024 pm 07:13 PM

Composer是一个PHP的依赖管理工具,可以帮助开发者有效地管理项目中的依赖关系。通过Composer,我们可以轻松地引入第三方库、框架以及其他项目所需的各种资源。创建一个Composer项目非常简单,只需按照以下步骤进行操作:首先需要确保在本地已经安装了Composer。可以在终端中运行composer-v命令来确认是否已经安装成功。在项目的根目录中

composer是什么插件composer是什么插件Dec 25, 2023 am 09:55 AM

​Composer是一个PHP的依赖管理工具,它可以帮助开发者在PHP项目中管理和安装依赖的库文件。Composer通过一个中央化的存储库来管理所有的依赖库文件,这个存储库包含了各种可用的依赖库的信息和版本信息。开发人员可以在项目中使用Composer来声明所需的依赖库,然后Composer会自动从存储库中获取并安装这些依赖库的最新版本到项目中的某个目录中。

什么是Composer,它与PHP的关系是什么?什么是Composer,它与PHP的关系是什么?May 12, 2023 pm 08:31 PM

随着现代Web开发技术的迅速发展,依赖管理成为了一个越来越重要的议题。无论是前端还是后端开发,我们需要引入各种各样的库和框架来达到更高的开发效率和更好的应用性能。而这些库和框架的组织、版本控制和安装管理问题则成为了一个值得思考和解决的难题。Composer就是为了解决PHP应用开发中依赖管理问题而推出的一个开源工具。它的作用类似于Node.js

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor