当前位置:网站首页>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
边栏推荐
- XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
- Go zero framework database avoidance Guide
- 2021-06-29 C escape character cancellation and use
- Experience of mathematical modeling in 18 year research competition
- GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
- Plato Farm元宇宙IEO上线四大,链上交易颇高
- Latex formula
- C migration project record: modify namespace and folder name
- [graph theory brush question-4] force deduction 778 Swimming in a rising pool
- 一. js的深拷贝和浅拷贝
猜你喜欢
vulnhub DC:1渗透笔记
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
[SQL] string series 2: split a string into multiple lines according to specific characters
[matlab 2016 use mex command to find editor visual studio 2019]
[PTA] get rid of singles
Resolve the eslint warning -- ignore the warning that there is no space between the method name and ()
[stack and queue topics] - sliding window
Es error: request contains unrecognized parameter [ignore_throttled]
Cmake project under vs2019: calculating binocular parallax using elas method
Preliminary understanding of cache elimination algorithm (LRU and LFU)
随机推荐
How do BIM swindlers cheat? (turn)
【栈和队列专题】—— 滑动窗口
Common form verification
Use of node template engine
Modeling based on catiav6
Learn to C language fourth day
黑客的入侵方式你知道几种?
[PTA] l1-002 printing hourglass
Easy to use nprogress progress bar
Matlab: psychtoolbox installation
缓存淘汰算法初步认识(LRU和LFU)
Imitation Baidu map realizes the three buttons to switch the map mode by automatically shrinking the bottom
MySQL stored procedures and functions
Unity solves Z-fighting
Learn to C language fourth day
Async function ------ ES6
Leetcode 1346. Check whether integers and their multiples exist
Rt-1052 learning notes - GPIO architecture analysis
Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
Leetcode 20. Valid parentheses