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

2020-04-29 09:08:51 浏览数 (1)

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:8000

3.模仿dingoapi 返回分页

代码语言:javascript复制

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

4.laravel-admin上传多张图片

controller:

代码语言:javascript复制
 $form->multipleImage('images', '上传图片');

model:

代码语言:javascript复制
 public function getImagesAttribute($value){ 
    $array = explode(',', $value); 
    return $array; 
 } 
 public function setImagesAttribute($value){ 
    $this->attributes['images'] = implode(',', $value); 
 }
 

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

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

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

代码语言:javascript复制
 [ComposerDownloaderTransportException]                                                                                     
  The "https://packagist.laravel-china.org/packages.json" file could not be downloaded: Peer certificate CN=`*.phphub.org' 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复制
[ComposerDownloaderTransportException]                                                                                                    
  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复制
[ComposerDownloaderTransportException] 
 The "https://packagist.laravel-china.org/p/league/fractal$15238fdcb46cea35d54e55c4b  
 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/

0 人点赞