About 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!
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('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()) { 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 largergit 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('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()) { 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;}
14. Docker configuration domestic source
sudo tee /etc/docker/daemon.json <<-'EOF'
Enter the following content, the address can be selected by yourself{
"registry-mirrors": ["https://uxk0ognt.mirror.aliyuncs.com"]
}
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
