laravel learning tutorial

PHP中文网
Release: 2023-03-10 20:40:01
Original
1568 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!