【玩转腾讯云】Laravel 笔记,持续更新中...

1.composer install或者其他操作报:

代码语言:javascript
复制
A version is required for an API group definition.

可能1:.env文件没有

2.laravel-admin 显示图片在图片地址前添加admin域名,例如:

代码语言:javascript
复制
127.0.0.1:8000/admin/127.0.0.1:8000/uploads/images/1.jpg

原因:.env设置APP_URL错误

代码语言:javascript
复制
错误:APP_URL=127.0.0.1:8000

正确:APP_URL=http://127.0.0.1

3.模仿dingoapi 返回分页

代码语言:javascript
复制

dataList = paginator->transform(function ($item){
data = transformer->transformData($item);
return $data;
});

4.laravel-admin上传多张图片

controller:

代码语言:javascript
复制
 form-&gt;multipleImage(&#39;images&#39;, &#39;上传图片&#39;);</code></pre></div></div><p>model:</p><div class="rno-markdown-code"><div class="rno-markdown-code-toolbar"><div class="rno-markdown-code-toolbar-info"><div class="rno-markdown-code-toolbar-item is-type"><span class="is-m-hidden">代码语言:</span>javascript</div></div><div class="rno-markdown-code-toolbar-opt"><div class="rno-markdown-code-toolbar-copy"><i class="icon-copy"></i><span class="is-m-hidden">复制</span></div></div></div><div class="developer-code-block"><pre class="prism-token token line-numbers language-javascript"><code class="language-javascript" style="margin-left:0"> public function getImagesAttribute(value){
array = explode(&#39;,&#39;, value);
return $array;
}
public function setImagesAttribute($value){
this-&gt;attributes[&#39;images&#39;] = implode(&#39;,&#39;, value);
}

5.接口请求数据库写字段写入不进去

代码语言:javascript
复制
model中$fillable添加字段

6.composer 无法下载扩展文件的问题

代码语言:javascript
复制
 [Composer\Downloader\TransportException]
The "https://packagist.laravel-china.org/packages.json" file could not be downloaded: Peer certificate CN=*.phphub.org&#39; di d not match expected CN=packagist.laravel-china.org'
Failed to enable crypto
failed to open stream: operation failed

原因:composer 全局下载换成中国镜像.

解决:下载源换回默认。修改 composer 配置

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


7.报bootstrap/cache directory must be present and writable.错误

mkdir cache

php artisan cache:clear

8. 报这个错误 Missing BC Math or GMP extension.

Hashids requires either theBC MathorGMPextension in order to work.

yum install php-bcmath

chown -R -v nginx:nginx /run/php-fpm/php-fpm.sock

9.file_put_contents(/): failed to open stream: Permission denied

1)php artisan cache:clear
2)chmod -R 777 storage

10.composer update报错

代码语言:javascript
复制
[Composer\Downloader\TransportException]
The "https://packagist.laravel-china.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error mess
ages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed

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

11.lavale换源

代码语言:javascript
复制
[Composer\Downloader\TransportException]
The "https://packagist.laravel-china.org/p/league/fractal%2415238fdcb46cea35d54e55c4b
3b27b4b96525d1f9909d9f01b69abff5ef0b57a.json" file could not be downloaded: SSL opera
tion failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed

composer config repo.packagist composer https://mirrors.aliyun.com/composer/