1. To install laravel, you can install it directly with composer, and then use laravel new xxx to create a new project
After composer (php package management tool) is installed on the server,
<span class="hljs-symbol">composer <span class="hljs-meta">global <span class="hljs-meta">require <span class="hljs-string">"laravel/installer=~1.1"</span></span></span></span>
export PATH=<span class="hljs-variable">$PATH<span class="hljs-symbol">:/root/.composer/vendor/bin/</span></span>
Then you can use the command
laravel new xxx
2. Configure the elegant link so that you can access it when defining the route
in location Add an extra
location / {
try_files $uri $uri/ /index.php?$query_string;
}
The port definition path here is Defined to public
/blog/public
3, automated testing
php vendor/bin/phpunit --bootstrap /ecmoban2/blog/bootstrap /autoload.php /ecmoban2/blog/tests/Feature/ExampleTest.php
or
phpunit --bootstrap /ecmoban2/blog/bootstrap/autoload.php /ecmoban2/blog/tests/ Feature/ExampleTest.php
4. artisan uses
to view automatically generated classes
php artisan list make
For example We create an Article controller
php artisan make:controller ArticleController
You can also create many things...
5. View usage rules
return view('articles.lists');
The above means that a view is returned. The view path is as follows. If the articles directory does not exist, create it manually. This method is dedicated to the view function
resources/views/articles/lists.blade.php
6. Routing Route rules
The above represents the effect obtained after visiting xxx.com/user, and the value of the $name variable is predefined in it
Route::get('user/{name?}', function ($name = 'JellyBool') { return 'Hello '. $name; });
#
The above is the detailed content of laravel learning tutorial. For more information, please follow other related articles on the PHP Chinese website!