当前位置:网站首页>PHP的Laravel与Composer部署项目时常见问题
PHP的Laravel与Composer部署项目时常见问题
2022-04-23 20:39:00 【小简(JanYork)】
我们在部署PHP项目时,其实大部分的PHP项目会创建环境检测与一键**Install
**页面。
但是,有许多的项目还采用了Composer
部署。
什么是Composer
至于什么是Composer
,我就简单说一下。
Composer
是 PHP 的一个依赖管理工具。我们可以在项目中声明所依赖的外部工具库,Composer
会帮你安装这些依赖的库文件,有了它,我们就可以很轻松的使用一个命令将其他人的优秀代码引用到我们的项目中来。
相当于Node
里面的npm
。
Laravel框架
Laravel
是一个开源PHP框架,功能强大且易于理解。它遵循模型 - 视图 - 控制器设计模式(MVC)。Laravel
重用了不同框架的现有组件,这有助于创建Web应用程序。这样设计的Web应用程序更加结构化和实用。
具体特点我就不说了,其中比较显著的是,依赖管理器完全基于composer
。
报错:php artisan key:generate
这个错误,一般有三个问题,对应解决一下。
报错1:PHP脚本占用内存太多,memory_limit默认128m不够用。 PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted 。 Composer命令失败: Composer内部增加memory_limit到1.5G.
报错2:PHP版本问题。
这个就对症分析就可以。
注意的是,有时候不是你项目PHP版本不行,而是你
composer
的版本没有对应。
报错3:需要更新composer。
composer update
Laravel 出现 No application encryption key has been specified.
首先,我们要看看有没有.env
文件,或者.env
文件后还追加了.example
后缀。
1、.env.example 改名使用命令 copy 修改为 .env。
此时可能还提示缺少了Key。我们使用命令生成。
2、使用命令 php artisan key:generate
获取密码,自动保存到 .env。
命令直接在终端运行就可以。
Composer获取依赖超时
首先判断是否存在这个依赖包。
其次,可能是国外的源,下载超时很正常,我们使用命令将源改为国内的源。
composer config -g repo.packagist composer https://packagist.phpcomposer.com
Composer
升级带来的坑: Undefined index: name
我在部署时也遇到了这个问题,我们可以直接尝试回滚版本或者降低版本,部署上去后再升级回来。
Undefined index: name
如果存在这个报错,那么我们可以这样:
# composer 降级
composer self-update --1
# 再次安装,即可!!!
composer install
或者不需要再次安装,我们直接运行第一句也可以。
composer self-update --1
至于其他方法,不建议,我也就不写了。
版权声明
本文为[小简(JanYork)]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_60750453/article/details/124250973
边栏推荐
- Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
- Bash script learning -- for loop traversal
- Leetcode 994, rotten orange
- JS arrow function user and processing method of converting arrow function into ordinary function
- An error occurs when the addressable assets system project is packaged. Runtimedata is null
- Solve the Chinese garbled code of URL in JS - decoding
- Easy to use nprogress progress bar
- [PTA] l1-002 printing hourglass
- Linux64Bit下安装MySQL5.6-不能修改root密码
- The problem of 1 pixel border on the mobile terminal
猜你喜欢
Come in and teach you how to solve the problem of port occupation
Matlab matrix index problem
上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
LeetCode 994、腐烂的橘子
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
go slice
Some basic configurations in interlij idea
【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行
Matlab analytic hierarchy process to quickly calculate the weight
随机推荐
Use of node template engine
LeetCode 1346、检查整数及其两倍数是否存在
Common form verification
一些接地气的话儿
Rt-1052 learning notes - GPIO architecture analysis
GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
Latex formula
黑客的入侵方式你知道几种?
Unity asset import settings
C migration project record: modify namespace and folder name
Solve the Chinese garbled code of URL in JS - decoding
Bash script learning -- for loop traversal
启牛学堂有用吗,推荐的证券账户是否安全
【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行
Automatically fill in body temperature and win10 task plan
Communication between RING3 and ring0
Create vs project with MATLAB
Go language development Daily Fresh Project Day 3 Case - Press Release System II
Leetcode 1346. Check whether integers and their multiples exist
Psychological formula for converting RGB to gray value