Let us quickly generate Laravel projects through simple bash.
This article teaches you how to use the docker image provided by D-Laravel to build an execution development environment for swoole.
After reading this article, you should be able to quickly create a swoole execution environment through D-Laravel.
environment confirmation
Notes
1. Currently, Swoole on D-Laravel can only use default as the Project directory. Therefore, one D-Laravel can only run one swoole project.2. Please confirm that your port 80 is not occupied by the host, otherwise you need to adjust the host in docker-compose-swoole.yml to open the port first,
For example, change to 8080:80, and change the port opened on the host side to 8080.
3. Please confirm that you are using the latest php image, at least the following version or later, to have the built-in swoole.so extension.
image: deviny/fpm:7.3.5
image: deviny/fpm:7.2.18
image: deviny/fpm:7.1.29
image: deviny/fpm:5.6.39
Enter the topic, the steps to create a swoole project are as follows:
1. In order to ensure that there are no port conflicts, it is recommended to stop other d-laravel in our operation first, if any.We can use the docker ps command to check whether there are still D-Laravel-related containers still running.
2. Directly clone the latest version of d-laravel and specify a new Project name.
The project name of swoole, you can order it yourself, for example: project1.
git clone https://github.com/DevinY/dlaravel.git swoole
3. In the above example, I created a Project named swoole. After cloning it, enter the directory of swoole
cd swoole
4. One d-laravel can only run one swoole, please create a default project. (default name cannot be changed)
./create default
5. After the fourth step is completed, the swoole package of laravel needs to be installed, and d-laravel uses the laravel-s package.If your D-Laravel has set aliases (ce and a), we can simply execute the aliases and complete the installation steps on the host side (host),
Or you can enter the container to execute the relevant installation instructions.
1. Host-side D-Laravel alias installation method:
#Enter the default project folder
cd sites/default
#Use the alias ce to represent the composer command to install laravel-s
ce require "hhxsv5/laravel-s:~3.5.0" -vvv
#Use the alias a to represent php artisan to release laravel-s
a laravels publish
Before the swoole environment is established, we can directly enter ./console swoole to see the installation instructions. 2. Installation method in the container:
If you don't know how to create an alias for D-Laravel, you have another option, enter into the container to install, the command is as follows:
#Use ./console to enter the container
./console
#Enter the project folder
cd default/
#Install laravel-s through composer
composer require hhxsv5/laravel-s:~3.5.0 -vvv
#publishRequired files
php artisan laravels publish
If you entered the container installation, after the completion, press the hotkey Ctrl+D to leave the container and return to the host (host), the screen is as follows:6. Switch to swoole mode
./console swoole
If you have built according to the drawings, I believe that success is guaranteed, you should be able to see a picture similar to mine. Above, you have completed the swoole development environment of D-Laravel. D-laravel uses a self-developed file watcher for file modification detection.
When initializing, you may have to wait a few seconds to see the webpage. In D-Laravel's swoole mode, the computer's IP can be accessed directly.
We can also use localhost or IP to connect to the website.
The tester presses command+r to reorganize the webpage, and you will find that it becomes super fast with ~~Laravel.
Finally, I want to say that I did not use swoole for development, if you want to use it in the Production version, please evaluate or test it yourself,
Swoole has those pits or those mines, please Google it yourself.
Here I just provide a way to execute swoole in the D-Laravel environment. Of course, the image of the latest version of D-Laravel PHP FPM has built-in swoole extensions.
In other words, after adding swoole.so to php.ini, your php can execute swoole-related commands and create various services, not limited to Laravel's swoole environment.
Seeing is believing:
The actual measurement of the same environment, the same code, the difference in page loading speed between non-use and use of swoole:swoole.com official website:
https://www.swoole.com/
laravel-s (integration of Laravel and swoole)
https://github.com/hhxsv5/laravel-s
No Comment
Post your comment