by Devin Yang
(This article was automatically translated.)

Published - 4 years ago ( Updated - 1 year ago )

It's very simple, just add an "alias":

alias laravel='docker run --rm -v ${PWD}:/ var/www/html -v ~/.dlaravel/cache:/home/dlaravel/.composer/cache -ti deviny/fpm:8.1.10 /home/dlaravel/.composer/vendor/bin/laravel' 

In this command, the current folder of our host (host) will be mounted, and we have seen -v ${PWD}.
The container side (to the right of the colon) is: /var/www/html, because it is the default path for the deviny/fpm image to build the container.
-ti followed by the image we want to use, here I use deviny/fpm:8.1.10 version.
--rm means that the created container can be removed after execution.

That is to say, we have executed the laravel installation command in the container through docker, because we have mounted the directory on the host side.
Therefore, the directory generated in the container can be kept on the host side.

Paste the above alias to the terminal to test the function of Laravel installer directly.
If you want to take effect permanently, you can add it to the startup file of your own shell.

We can use $0 to see what shell we are using.

echo $0

Add the alias settings to the file.
For example: add /bin/zsh to
or bash

Remember to execute source once to update.
For example, I am zsh

source ~/.zsh

Tags: docker php cli

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


How to simply use Docker to create an internet command line speed test program?

How to simply use Docker to create an internet command line speed test program? Here we use the python program speedtest-cli Will use Docker for the main use case, for example, I want to test the speed in my NAS, Although there is python in my NAS, but there is no pip command, it feels much safer to use Docker at this time. Of course, your NAS needs to be able to run Docker :). Or, I am in a MacOS environment, and I don't want to install speedtest-cli into my MacOS. At this time, it is not bad to use Docker to build a simple execution environment by yourself.


Talking about PSRs

The full name of PSR is called "PHP Standards Recommendations" (PHP Standards Recommendations). A proposed specification developed by FIG (PHP Framework Interoperability Group), This group was initiated by some framework developers in php|tek in 2009, from the first 5 to more than 20 now. There are many numbers in the "PHP Standard Recommendations", each number represents a different specification.


How to use find to delete old files based on the creation time

This function is very useful, but be very careful, read it first and then delete it, if you make a wrong directory, you will die miserably