当前位置:网站首页>Common problems in deploying projects with laravel and composer for PHP

Common problems in deploying projects with laravel and composer for PHP

2022-04-23 20:45:00 Jan York

We are deploying PHP Project time , In fact, most of them PHP The project will create environment detection and one click **Install** page .

however , Many projects also use Composer Deploy .

What is? Composer

As for what is Composer, Let me just say it briefly .

Composer yes PHP A dependency management tool for . We can declare the dependent external tool library in the project ,Composer  Will help you install these dependent library files , With it , We can easily use a command to reference other people's excellent code into our project .

amount to Node Inside npm.

Laravel frame

Laravel It's open source PHP frame , Powerful and easy to understand . It follows the model - View - Controller design mode (MVC).Laravel Reusing existing components of different frameworks , This helps create Web Applications . Designed like this Web Applications are more structured and practical .

I won't talk about the specific features , One of the more remarkable is , The dependency manager is completely based on composer.

Report errors :php artisan key:generate

This mistake , There are generally three questions , Solve it accordingly .

Report errors 1:PHP Script takes up too much memory ,memory_limit Default 128m Not enough use . PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted . Composer Command fails : Composer Internal increase memory_limit To 1.5G.

Report errors 2:PHP Version of the problem .

This is based on symptomatic analysis .

Pay attention to is , Sometimes it's not your project PHP The version doesn't work , It's you composer The version of does not correspond to .

Report errors 3: You need to update composer.

composer update

Laravel appear No application encryption key has been specified.

First , We need to see if there is .env file , perhaps .env After the file is added .example suffix .

1、.env.example Change the name and use the command copy It is amended as follows .env.

At this time, it may also indicate that Key. We use the command to generate .

2、 Use command  php artisan key:generate  Get password , Auto save to .env.

The command can be run directly at the terminal .

Composer Get dependency timeout

First, determine whether the dependency package exists .

secondly , It may be a foreign source , Download timeout is normal , We use the command to change the source to the domestic source .

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

Composer  The pit brought by the upgrade : Undefined index: name

I also encountered this problem during deployment , We can directly try to roll back the version or reduce the version , Deploy it and then upgrade it back .

Undefined index: name

If this error exists , So we can do this :

# composer  Downgrade 
composer self-update --1
 
#  Re install , that will do !!!
composer install

Or you don't need to install it again , We can also run the first sentence directly .

composer self-update --1

As for other methods , Don't suggest , I won't write any more .

 

版权声明
本文为[Jan York]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232039376011.html