In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to create projects and test configurations for Laravel 5.7developing blog applications. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Create a blog project
First, install a new Laravel project blog57 locally via Composer:
Composer create-project laravel/laravel blog57-prefer-dist
You can also install laravel new blog57. The advantage of using Composer is that you can switch between different versions. For example, if you are using Laravel version 5.5, you can specify to install the new application version 5.5: composer create-project laravel/laravel blog55-- prefer-dist 5.5.*.
Add a new database named blog57 to the database, and then modify the database configuration information of the .env file in the root directory of the blog57 application.
Then run the following command under the application root directory to initialize the front-end resources:
Npm install
Then configure the local virtual domain name of the application as blog57.test, and you can access the application through http://blog57.test in the browser:
2. Run the test
Unit testing and functional testing (based on PHPUnit) capabilities for Laravel integration are available right out of the box, and even provide simple unit and functional testing examples.
To run PHPUnit, simply run the vendor/bin/phpunit command from the project root:
If you want to run PHPUnit through Composer, you can configure it in the composer.json file as follows:
"scripts": {
"test": [
"vendor/bin/phpunit"
]
...
}
This allows you to run the test through composer test.
PHPUnit configuration in Laravel
In the root directory of the newly created Laravel project, there is a phpunit.xml file that contains the configuration information for PHPUnit.
If you look at the phpunit.xml file, you will see that the test file is located in the tests directory, where there are already two sample test files by default:
Unit/ExampleTest.php-contains a testBasicExample () test, and the Unit directory contains unit test classes.
Feature/ExampleTest.php-also includes a testBasicExample () test to test whether the return status code of the home page of the access application is a functional test class contained in the 200grad feature directory.
Both the unit test and functional test classes inherit from the Tests\ TestCase base class, and the TestCase class provides many methods and properties for Laravel applications for unit testing and functional testing.
Let's look at the testBasicExample () method in Feature/ExampleTest.php:
Public function testBasicTest ()
{
$response = $this- > get ('/')
$response- > assertStatus
}
The test accesses the application's home page and asserts whether the response status code is 200. Is there a simpler test implementation?! We can see the effect of the page directly by configuring the virtual domain name access page, and we can achieve test-driven development by writing unit tests and functional tests, and complete application testing and iterative development more efficiently.
Thank you for reading! This is the end of the article on "how to create projects and test configurations for Laravel 5.7blog applications". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.