by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

If you haven't heard of D-Laravel, let me introduce it. D-Laravel is a Laravel and docker execution environment built with docker-compose.
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

When the container is started, we can view the compiled related php extensions through ./console ext. For example, in the picture below, we can see swoole.so

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


 

Tags: laravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


laravel storage

How do I sync files with Laravel's Storage's sftp driver

The installation and setting of SFTP is beyond the scope of this article. If you want to know more, I suggest you read another article https://www.ccc.tc/article/Laravel-SFTP-Driver-Configuration. In this article, I will use a very fast Sample. Demo How do I use the self-built artisan command to synchronize the remote data to the local end. Some people may ask why rsync is not used. This article is to introduce the use of Storage to synchronize files. 🤪Let’s look directly at the code, I set up an sftp disk called ccc in config/filesystems.php.

laravel example, laravel teaching, livewire example, laravel

How to set cultural error messages in Laravel Livewire components

This article uses a simple Laravel livewire example to see how the livewire component verifies user input errors and displays Chinese error messages.

laravel

Facebook test user

Is there anyone who uses OAuth for website user login like me? There is a "test user" on the Facebook developer page. It can be used to test whether the function of Facebook is normal, Because when the website moved to Google’s GCE, for some reason, I actually posted one more in the $fillable array of Laravel’s User model~, Normally the program works fine, but when a new user logs in, an error is shown to you. I keep hearing people say that I can't log in to this website to leave a message. I want to say that I am very normal. @@ After using the test user test today, ha, I found that the login function on my website has been broken for a long time.