简体   繁体   English

如何在没有cURL命令行的情况下安装Composer?

[英]How do I install Composer without cURL command line?

I need to install Composer on a shared hosting service. 我需要在共享主机服务上安装Composer。 This service supports cURL, but does not support SSH access. 此服务支持cURL,但不支持SSH访问。 As a result, I cannot run cURL commands from the command line. 因此,我无法从命令行运行cURL命令。

Is it possible to install cURL without a command line? 是否可以在没有命令行的情况下安装cURL? Perhaps a PHP script that I run only once? 也许我只运行一次PHP脚本?

Install the composer.phar file locally and then just upload it to your hosting provider. 在本地安装composer.phar文件,然后将其上传到您的托管服务提供商。

Alternatively, you can download composer.phar from their website. 或者,您可以从他们的网站下载composer.phar

However, it's unlikely that you'll be able to run it. 但是,你不太可能运行它。 Unless you are using it programatically, I recommend you install all of your dependencies locally into a release branch/package and upload that to your hosting provider. 除非您以编程方式使用它,否则我建议您将所有依赖项本地安装到发布分支/包中,然后将其上载到您的托管服务提供商。

The download page of the composer site has instructions for those missing curl that only require php: 作曲家网站的下载页面提供了那些只需要php的缺少curl的说明:

php -r "readfile('https://getcomposer.org/installer');" | php

The above is the recommended way, but alternatively if you don't want to run the installer and all the config checks it does, you can just download the phar file from https://getcomposer.org/composer.phar - either using your browser or via wget https://getcomposer.org/composer.phar (if you have access to wget). 以上是推荐的方法,但是如果您不想运行安装程序并进行所有配置检查,则可以从https://getcomposer.org/composer.phar下载phar文件 - 使用您的浏览器或通过wget https://getcomposer.org/composer.phar (如果您有权访问wget)。

Get the file from https://getcomposer.org/composer.phar https://getcomposer.org/composer.phar获取文件

And then use with php prefix of every commands. 然后使用每个命令的php前缀。

Example of a batch on windows OS: C:\\xampp\\php\\php composer.phar create-project laravel/laravel C:\\xampp\\htdocs\\laravel42 4.2 --prefer-dist Windows操作系统上的批处理示例: C:\\xampp\\php\\php composer.phar create-project laravel/laravel C:\\xampp\\htdocs\\laravel42 4.2 --prefer-dist

You can also create a simple batch file to do it globally: 您还可以创建一个简单的批处理文件来全局执行:

:: File Name should composer.bat
@ECHO OFF
SET PATH=%PATH%;%~dp0
setlocal DISABLEDELAYEDEXPANSION
SET COMPOSER_PROCESS_TIMEOUT=5000
C:\xampp\php\php "%~dp0composer.phar" %*

Now you are able to use it VIA evnironment setup or directly to this batch file. 现在您可以使用VIA evnironment设置或直接使用此批处理文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM