search
HomePHP FrameworkThinkPHPAbout Laradocke running TP project

The following is the thinkphp framework tutorial column to introduce to you about the Laradocke running TP project, I hope it will be helpful to friends in need!

About Laradocke running TP project

1. When laradock comes up for the first time, the build process is very slow

Due to the problem of pulling the container The image is overseas by default, so before docker-compose up the container, look for the following text in the .env file

CHANGE_SOURCE=``false

and then change false to false true, and look for the following text

#UBUNTU_SOURCE=aliyun

Remove the # in front, that is, remove the comment, and change the default foreign mirror source to the domestic one with the fastest speed The mirror source of aliyun

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

WORKSPACE_TIMEZONE=UTC

Change UTC to PRC

Then execute the command

docker-compose up -d nginx mariadb

Choose the container you need to start

Compare it yourself After the build time, under 20M bandwidth, if the mirror source is not changed, it can be as fast as one hour or as slow as one day. After the change, it only takes 10min

2. laradock is starting An error is reported during the container build workspace process

If the relevant text "raw.githubusercontent.com" appears, bind the domain name to the ip in local hosts

Take linux as an example

vim ``/etc/hosts

Enter "199.232.28.133 raw.githubusercontent.com" in the file

3. Composer install is slow

After installing laradock, use git to pull the tp5 framework from the third-party hosting warehouse in the worksapce container, and then install the framework dependencies. At this time, composer install is very slow. If you need to replace the domestic source, execute the following command

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

4. Composer ignores the version number to install

If composer install encounters an error message Your requirements could not be resolved to an installable set of packages., you can ignore the version number for installation. , execute the following command

composer ``install --ignore-platform-reqs

5. Composer installs the database migration tool for tp5

The migration tool for tp5.0 is 1., and for tp5.1 is 2.. If the version number is not specified, the latest one will be installed by default. Migration tool, execute the following command

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

##6. When configuring the database connection in tp5 in laradock, the host fills in the container name

I use the mariadb container, so the following configuration

'host'=>'mariadb'

7. tp5 gives full permissions to runtime

##hmod -r runtime 777

8. TP5 captures exceptions thrown by mysqlAdd a backslash in front of the catch parameter Exception to indicate that the capture will start from the lowest Exception

catch``(\Exception)

9. When doing the image upload interface, mkdir reported an error no permission In order to facilitate the reference of pictures, I specified the picture storage directory as public/uploads, but an error was reported. It can be solved by giving public full permissions

chmod -r public 777

10. Permission verification for the back-end interfaceoauth2 is a very good authorization mechanism. PHP has a good library https://github.com/thephpleague/ oauth2-server, but it is very helpless. Unlike laravel, which has passport, it also supports Drupal, cakephp and other frameworks

It is also good to use Json-web-token https://github.com/lcobucci/jwt

11. Cross-domain processingIn tags.php in the application directory, add the file that is executed when the application is initialized. For example, I put the cross-domain The domain is placed in the applicationapi/behavior/CORS.php file, and header

// Application initialization``'app_init'

is issued during the application initialization process => [` `'app\\api\\behavior\\CORS'``], Cross-domain files

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

12. git push/pull requires identity verification, enter the user name and password multiple times

In the Linux environment, in the warehouse directory Execute

git config --global credential.helper store

##13. git push stuck

Set to send packets without borders, and set the HTTP request buffer to be larger

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

14. nginx does not support tp5 pathinfo

Change the .conf file configuration corresponding to the project

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

Change Former location ~ .php$ {

 location ~ \.php { 
    try_files $uri /index.php =404;
    fastcgi_pass php-upstream;
    fastcgi_index index.php;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    # 添加部分↓↓↓↓
    # Set var PATH_INFO
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    #  添加部分↑↑↑↑
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   
    #fixes timeouts
    fastcgi_read_timeout 600;
    include fastcgi_params;}
I will find time to learn the specific options

14. Docker configuration domestic source

sudo tee /etc/docker/daemon.json

##vim /etc/docker/daemon.json

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

{
  "registry-mirrors": ["https://uxk0ognt.mirror.aliyuncs.com"]
  }
#Then execute the following instructions

systemctl daemon-reload

systemctl restart docker

##NoteAs we all know, cloning from github has always been It is relatively slow. You can choose to use Code Cloud to import commonly used warehouses into your own Code Cloud workspace in advance. When you need to use it, clone it through Code Cloud                  

                                             

The above is the detailed content of About Laradocke running TP project. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.