by Devin Yang
(This article was automatically translated.)

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

This article briefly introduces how to execute php artisan in the container under the alias a of D-Laravel.
In addition to executing the commands in the container on the host side through simple bash, you can also understand the operation behind it.

First of all, we know that D-Laravel can get the command of alias a through ./console alias a .
alias a="../../artisan.sh"

When we are in the folder of a D-Laravel Project on the host side (MacOS or Linux), such as sites/proj1.
We entered a --version alias, and we can run out the version number of Laravel, why?
In fact, executing a alias is to execute the bash artisan.sh in the dlaravel directory .
Through this bash, it is equivalent to helping us execute the official instructions as follows:
docker-compose exec -u dlaravel php php proj1/artisan --version

First, let’s check the version of docker-compose we use, we can use the command docker-compose version .
If your execution result is different from this article, you may need to update your docker-compose version.


Getting to the point, now let's take a look at what good things have been done after the a --version converted docker-compose command.
Click the image below to enlarge it:
docker-compose help

Therefore, after becoming an alias, it is relatively simple, and you can execute Laravel's artisan instructions without entering the php container.
Here I use the docker-compose standard command, enter the container, and then perform the process of php artisan --version

For example, at least three lines of instructions are required to execute the php artisan instruction to the proj1 folder.
1. docker-compose exec -u dlaravel php bash (execute the bash of the php container service name, so we have entered the container)
2. cd proj1 (enter the folder of proj1, in the container, the default working directory is /var/www/html)
3. php artisan --version (moved, executed to proj1's php artisan --version)

Instead of the a alias provided by D-Laravel , we only need a --version .

So, by analogy, if we want to see the php service in the container, the php version, what is the command?
php --version

Or, we want to find out what is the Linux core version used in the container of the php service?
uname -a

In the docker-compose environment of D-Laravel, the container service name of mysql is db.
Therefore, we exec db mysql to execute the mysql command in the container and enter mysql.
mysql

Hope this article, you can understand, when we use the simple alias, behind the scenes of D-Laravel is how to operate through the official command.

Tags: dlaravel

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


dlaravel

[D-Laravel] about chowner.

About D-Laravel's Chowner This article explains the function of chowner in D-Laravel. If you are a Linux user, you may need to do this.

php,docker,dlaravel

A brief introduction to the phpenv container environment I built

I don't have time to shoot an introduction video, so I'll just grab some pictures and introduce the container environment deviny/phpenv I use. https://github.com/DevinY/phpenvphpenv can be regarded as an evolutionary version of my previous D-Laravel open source project, conceptually extending the use of many Dlaravel operation methods. The update of the container tends to be controlled by the user to build his own image, so I am not very good at changing the version number. In fact, the php version number of D-Laravel seems to have not been changed for a long time:p

dlaravel

How to start supervisor on D-Laravel

Since queue workers are a long-running program, we need a program manager supervisor to monitor whether the process on the Linux system is running continuously. For example, when the queue:work operation fails, the queue:work process can be automatically restarted. Fortunately, D-Laravel has a built-in supervisor, so you don't need to install it yourself to use it. This article briefly introduces how we start the supervisor in the container.