preface
In actual projects, the environment is already installed and configured by default. If not, refer to my Laravel column.
Install laravel and install plugin
1.1 installation laravel
Create an empty folder on your desktop:In the terminal go to this folder and enter the command:Composer creation-project laravel/laravel=5.8.17 --prefer -- dist./
As follows:
1.2 Installing development Plug-ins
This plugin allows you to develop faster and allows you to track source code. Enter the following command on the terminal:composer require barryvdh/laravel-ide-helper
Once installed, type on the project command linephp artisan ide
, will generate a prompt retrieval command:Enter a command on the command linephp artisan ide-helper:generate
This file is just a list of all your classes. Then we write in the editor, there is a response prompt, and can follow the source location.
Ii. Running project and configuration
2.1 Configuring a Virtual Host and Binding the hosts File
Configure apache (here don’t understand the configuration of input code can be directly to the terminal/Applications/MAMP/conf/apache/extra/HTTPD – vhosts. Open the conf can configuration, You can also check out my blog MAC Environment configuration or Window Environment Configuration) :
<VirtualHost *:80>
The email address of the site administrator, which is displayed when the site generates an error of 500 (internal server error)
ServerAdmin 136072944@qq.com
# Site to bind to the domain name
ServerName laravelproject.com
ServerAlias localhost
Make sure to set the log, the log can access us for system statistics
# Log is not automatically created directory need to be manually created, file is automatically created
# Error log
ErrorLog "/Users/justin/Desktop/laravelproject/logs/error.log"
# Success log
CustomLog "/Users/justin/Desktop/laravelproject/logs/access.log" combined
# The root directory of the site
DocumentRoot "/Users/justin/Desktop/laravelproject/public"
DirectoryIndex index.php
<Directory "/Users/justin/Desktop/laravelproject/public">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
allow from All
</Directory>
</VirtualHost>
Copy the code
Then create it in the project root directorylogs
Folders (folders are not automatically generated, log files are automatically generated) :
Modify the hosts file:Then restart theMAMP
, enter:http://laravelproject.com/
, the effect is as follows:
2.2 Configuring database Connections
Make the corresponding configuration Settings in the project. Env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravelproject
DB_USERNAME=root
DB_PASSWORD=root
DB_PREFIX=jt_
Copy the code
1, create a new database:2. Configure the laravel database connection configuration
2.3 Localization Configuration
Configure the config/app.php file time zone, faker, and verify the localization configuration
# locale => ‘zh_CN’ #faker Chinese ‘faker_locale’ => ‘zh_CN’
Go to thehttps://packagist.org
Download the language pack:See this article for language pack configuration Faker 英 文 configuration:
2.4 Deleting default files or Directories
app/User.php
database/factories/UserFactory.php
resources/views/welcome.blade.php
database/migrations/
All files below
Git source code management
New warehouse on Code Cloud:And then:
Then,git add .
git commit -m "first commit"
git remote add origin https://gitee.com/Counterrr/laravelproject.git
git push -u origin master
On the way to learning PHP, if you find this article helpful to you, then please pay attention to like comment 3 times, thank you, your must be another support of my blog.