Composer 踩坑之 require

2024-09-01 15:18
文章标签 composer require

本文主要是介绍Composer 踩坑之 require,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

异常一:file could not be downloaded

使用 composer require 安装依赖包时,出现 file could not be downloaded

Jason:package jason$ composer require "overtrue/package-builder" --prefer-source[Composer\Downloader\TransportException]The "https://packagist.phpcomposer.com/p/provider-2019-01%24fea7e532df036d6561316b44b5194b84d8bdb92b6c81cf8f07d0afb25b0a2b05.json" file could not be downloaded (HTTP/1.1 404 Not Found)require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...Jason:package jason$

这是切换 Compser 源引起的,
方式一(推荐):可以切换下其它的 composer 源,如:切换到 packagist.laravel-china.org

composer config -g repo.packagist composer https://packagist.laravel-china.org

方式二:可以多次尝试下,无法解决时执行下 composer update;在这里通过 composer update 后可正常安装依赖。

Jason:package jason$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Jason:package jason$
Jason:package jason$Jason:package jason$ composer require "overtrue/package-builder" --prefer-source
Using version ^1.0 for overtrue/package-builder
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 7 installs, 0 updates, 0 removals- Installing symfony/polyfill-ctype (v1.11.0): Cloning 82ebae0220 from cache
...

异常二:[Runtime Exception] vendor does not exist and could not be created

使用 root 进行 composer 安装时(尽量避免使用 root 执行,特别是生产环境),出现:

[root@vm shop]# composer require encore/laravel-admin "1.6.8"
Do not run Composer as root/super user! See https://getcomposer.org/root for details
^C
Installation failed, reverting ./composer.json to its original content.
[root@vm shop]#

切换到普通用户,又再次出现权限不够:

[jason@vm shop]$ composer require encore/laravel-admin "1.6.8"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals[RuntimeException]/home/www/shop/vendor/doctrine/event-manager does not exist and could not be created.require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...[jason@vm shop]$

项目本身是由 FTP 用户上传上来的,所以普通用户 jason 对其权限不足,首先考虑为其添加 www,ftp 用户组:

sudo usermod -a -G www jason
sudo usermod -a -G ftp jason

仍然不行。
最后只好将 vendor 的属主改为普通用户 jason

[jason@vm shop]$ sudo chown -R jason:jason vendor/
[jason@vm shop]$

再次安装:

[jason@vm shop]$ composer require encore/laravel-admin "1.6.8"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals- Installing doctrine/event-manager (v1.0.0): Downloading (100%)- Installing doctrine/cache (v1.8.0): Downloading (100%)- Installing doctrine/dbal (v2.9.2): Downloading (100%)- Installing symfony/dom-crawler (v4.2.5): Downloading (100%)- Installing encore/laravel-admin (v1.6.8): Downloading (100%)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
encore/laravel-admin suggests installing intervention/image (Required to handling and manipulation upload images (~2.3).)
encore/laravel-admin suggests installing spatie/eloquent-sortable (Required to built orderable gird.)[ErrorException]file_put_contents(./composer.lock): failed to open stream: Permission deniedrequire [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...[jason@vm shop]$

提示 composer.lock 文件没有权限,将 composer.lock 的属主也修改到 jason

[jason@vm shop]$ sudo chown -R jason:jason ./composer.lock
[jason@vm shop]$
[jason@vm shop]$ composer require encore/laravel-admin "1.6.8"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: encore/laravel-admin
Discovered Package: fideloper/proxy
Discovered Package: laravel/nexmo-notification-channel
Discovered Package: laravel/slack-notification-channel
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
[jason@vm shop]$

安装成功。

这篇关于Composer 踩坑之 require的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1127302

相关文章

uniapp vite3 require导入commonJS 的js文件方法

vite3 导入commonJS 方式导出 在Vite 3中,你可以通过配置vite.config.js来实现导入CommonJS(CJS)风格的模块。Vite 默认支持ES模块导入,但如果你需要导入CJS模块,可以使用特定的插件,比如@originjs/vite-plugin-commonjs。 首先,你需要安装插件: npm install @originjs/vite-plugin-c

Composer 使用小技巧

1. 仅更新单个库 只想更新某个特定的库,不想更新它的所有依赖: composer update foo/bar 此外,这个技巧还可以用来解决“警告信息问题”。你一定见过这样的警告信息: Warning: The lock file is not up to date with the latest changes in composer.json, you may be getting

Composer 学习笔记

Composer – 是一个新的安装包管理工具,服务于 PHP 生态系统(PHP依赖管理工具) 包含了两个部分:Composer 和 Packagist。 Composer Composer 是一个命令行工具,它的使命就是帮你为项目自动安装所依赖的开发包。Composer 包含了一个依赖解析器,用来处理开发包之间复杂的依赖关系;另外,它还包含了下载器、安装器等。 Packagist Pa

手动安装 composer.phar

手动安装#        将 composer.phar 文件 放在你要安装的目录下 ,然后进入cmd命令框,输入以下命令就会多出一个 composer.bat 文件 代表安装成功 echo @php "%~dp0composer.phar" %*>composer.bat

Cocos2d+Lua 游戏开发中的技巧系列之一 Lua require的语法糖

参考文档  --- https://blog.csdn.net/lovesmiles/article/details/80939240 笔记: Lua/JS尾调用   http://www.ruanyifeng.com/blog/2015/04/tail-call.html Lua的闭包详解   (和JS一吊样) Lua中的元表与元方法(_index与_newIndex区别) https:/

Hyperledger Composer 查看Fabric网络连接配置信息

// 首先进入安装了fabric的用户的主目录cd ~// 列出所有文件夹ls -la// 找到.composer并进去cd .composer// 配置文件位置// /home/fabric/.composer/cards/admin@bikesharing-network/connection.json

Hyperledger Fabric 或 Composer 查看当前区块链网络的区块生成机制、多长时间、多少个交易

// 1. 进入docker,获取当前区块链的配置信息,并存为config.pb# peer channel fetch config -c composerchannel ./config.pb --orderer orderer.example.com:7050   // 2. 将docker中的config.pb拷贝到Ubuntu主机中$ docker cp b7200c1b

Lua基础之模块与require

模块 Lua可以利用table实现模块加载 方法: 从require传入的参数中获取模块名或直接自定义变量名;初始化一个空table;在全局环境_G中添加模块名对应的字段,将空table赋值给这个字段;在package.loaded中设置该模块;设置环境变量。 例如: local moduleName = ... -- 模块名,可以在这里直接指定local M = {}

Lua基础之dofile、loadfile、require的区别

loadfile 特点:只编译,不运行。 一个lua文件是作为一个代码块(chunk)存在的,其实质就是一个函数,loadfile编译代码成中间码并且返回编译后的chunk作为一个函数,而不执行代码 ,并且loadfile一旦出错不会抛出错误信息而是返回错误代号。一旦发生错误,loadfile会返回nil和错误信息,这样我们就可以自定义错误处理。 想要通过loadfile加载并执行,可