Laradocke runs TP project


1、 When laradock was first up, the build process was very slow

Since the image of the pull container is foreign by default, look for the following text in the. Env file before docker compose up the container


Then change false to true and look for the following text


Remove the ා, that is, remove the annotation, and change the default image source in foreign countries to the image source of aliyun, which is fast in China

Then change the time zone of workspace to China time zone and find the following text


Change UTC to PRC

Then execute the command

docker-compose up -d nginx mariadb

Choose the container you want to start

Comparing the time of build by yourself, under the bandwidth of 20m, if you do not change the image source, it will be one hour faster and one day slower. After the change, it will only take 10 minutes

2、 Laradock reported an error in the process of starting container build workspace

If relevant text appears“ ”, then bind the domain name to IP in local hosts

Take Linux as an example

vim ``/etc/hosts

Enter “” in the file ”That’s it

3、 Composer install is slow

After installing laradock, pull the TP5 framework from the third-party hosting warehouse in the worksapce container with git, and then install the framework dependency. At this time, composer install is very slow, and the domestic source needs to be replaced. Execute the following command

composer config -g repo.packagist composer https:``//packagist``

4、 Composer ignore version number installation

If you encounter the error prompt of your requirements could not be resolved to an installed set of packages. You can ignore the version number installation and execute the following command

composer ``install --ignore-platform-reqs

5、 Compiler installs TP5 database migration tool

The migration tool for tp5.0 is 1Tp5.1 is 2If you do not specify the version number, the latest migration tool will be installed by default. Execute the following command

composer require topthink``/think-migration``=1.*

6、 When TP5 configures database connection in laradock, host fills in container name

I use MariaDB as the container, so the configuration is as follows


7、 TP5 gives runtime full permissions

hmod -r runtime 777

8、 TP5 catches the exception thrown by mysql

The catch parameter exception is preceded by a backslash to indicate that the capture starts from the lowest exception


9、 MKDIR reports an error of no permission when using the image upload interface

To facilitate the reference of images, I specify the image storage directory as public / uploads. However, an error is reported, which can be solved by giving full permission to public

chmod -r public 777

10、 Back end interface time authority verification

Oauth2 is a very good authorization mechanism. PHP has a good…But it’s helpless. Unlike laravel, which has a passport, it also supports Drupal, CakePHP and other frameworks

It’s also good to use JSON web

11、 Cross domain processing

In the application directory tags.php For example, I put the cross domain in application API / behavior/ CORS.php In the application initialization process, the header is issued

//App initialization_ init' => [``'app\\api\\behavior\\CORS'``],

Cross domain file

namespace app\api\behavior; use think\Response; class CORS
{ public function appInit(&$params)
    { header('Access-Control-Allow-Origin: *');
    header("Access-Control-Allow-Headers: token,Origin, X-Requested-With, Content-Type, Accept");
    header("Access-Control-Allow-Methods:GET, POST"); 
        if (request()->isOptions()) {

12、 Git push / pull needs to verify the identity and enter the user name and password multiple times

In Linux environment, execute in the warehouse directory

git config --global credential.helper store

13、 Git push stuck

Set the packet unbounded, and set the HTTP request buffer larger

git config --global sendpack.sideband false git config --global http.postBuffer 524288000

14、 Nginx does not support pathinfo for TP5

Change the configuration of the. Conf file corresponding to the project

location / {

     try_files $uri $uri/ /index.php$is_args$args;Add partif (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?s=$1 last;
     }Add part}

Location ~. PHP $before change{

 location ~ \.php { 
    try_files $uri /index.php =404;
    fastcgi_pass php-upstream;
    fastcgi_index index.php;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;#Add partvar PATH_INFO
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;#Add partSCRIPT_FILENAME $document_root$fastcgi_script_name;   
    #fixes timeouts
    fastcgi_read_timeout 600;
    include fastcgi_params;

I’ll take some time to learn the specific options

14、 Domestic source of docker configuration

sudo tee /etc/docker/daemon.json <<-'EOF'

vim /etc/docker/daemon.json

Enter the following content, the address can be selected by yourself

  "registry-mirrors": [""]

#Then execute the following instructions

systemctl daemon-reload

systemctl restart docker


As we all know, cloning from GitHub is always slow. You can choose to use code cloud. Import commonly used warehouses into your own code cloud workspace in advance, and clone through code cloud when you need to use it

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

The world is bustling and bustling for profit