How do I install Composer without cURL command line? - php

I need to install Composer on a shared hosting service. This service supports cURL, but does not support SSH access. As a result, I cannot run cURL commands from the command line.
Is it possible to install cURL without a command line? Perhaps a PHP script that I run only once?

Install the composer.phar file locally and then just upload it to your hosting provider.
Alternatively, you can download composer.phar from their website.
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 -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).

Get the file from https://getcomposer.org/composer.phar
And then use with php prefix of every commands.
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
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.

Related

How can I install composer in live server cpanel

I want to use php spreadsheet package and from their site, I was told to install composer on cpanel but have met little success on the internet trying to figure out how to do it.
Please, who can put me through on how to install composer on liveserver
You can use SSH for this (alternatively using cron jobs to run the commands will also work - way more tedious)
Login to your cPanel account via SSH
Make directory for your composer (can also be used for other executables that you might store)
mkdir ~/composer
cd ~/composer
Download composer
wget https://getcomposer.org/download/1.6.5/composer.phar
Change the name of composer and make it executable
mv composer{.phar,}
chmod +x composer
You will now be able to call composer by
php ~/composer/composer install
But it's more convenient to have it run by just invoking composer in your terminal. For this add the ~/composer directory to your $PATH. I'm using VIM for text editing so
vim ~/.bashrc
Append those two lines at the bottom
PATH=~/composer:$PATH
export PATH
Exit and login via SSH again - you will be able to freely call composer in your terminal

how to create autoload under vendor directory for php rabbitmq

I m new to php and rabbitmq in debian(Linux). I have installed xampp, rabbitmq and also installed composer.phar in project directory using below command
/opt/lampp/htdocs/rabbitmq_demo# curl -s https://getcomposer.org/installer | /opt/lampp/bin/php
Now I use Composer to install the dependencies of the project using below command
composer.phar install
but it thrown an error as below
bash: php: command not found
I have preferred the link https://getcomposer.org/doc/00-intro.md
I want to prepare autoload.php
Please help me to create autoload under vendor directory.
You do not have a php cli program installed on your computer or it is not in your current $PATH variable. Please install PHP first or correct your $PATH environment variable.
Once you have this, run the composer.phar install again. This will download all dependencies listed in your composer.json file. Once the program completes, you will have a file ``vendor/autoload.php`. You can just require this file at the beginning of your own script and everything will be taken care of.
You need to add the path to the PHP command line (CLI) in the XAMPP install, to your bash environment. (You'd think the installer would do this!)
The XAMPP PHP CLI on Debian is at /opt/lampp/bin/php
So you need to add /opt/lampp/bin to your $PATH environment variable.
See this answer for the various options in modifying your path depending on who you want to be able to run PHP.
/etc/login.defs
/etc/environment
/etc/profile
~/.bashrc
In one of those files, you append to the path thus:
PATH=$PATH:/opt/lampp/bin
and re-login.

How do I install Composer on a shared hosting?

I have these things:
the file http://api.odtu.lu/composer.phar
http://api.odtu.lu/phpinfo.php
ftp access
cPanel
Cron jobs on FreeBSD
PHP, Perl, CGI-BIN, Python, Curl.
How can I install Composer? (My aim is to install Restler)
Edit: I do not have SSH access.
This tutorial worked for me, resolving my issues with /usr/local/bin permission issues and php-cli (which composer requires, and may aliased differently on shared hosting).
First run these commands to download and install composer:
cd ~
mkdir bin
mkdir bin/composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar bin/composer
Determine the location of your php-cli (needed later on):
which php-cli
(If the above fails, use which php)
It should return the path, such as /usr/bin/php-cli, /usr/php/54/usr/bin/php-cli, etc.
edit ~/.bashrc and make sure this line is at the top, adding it if it is not:
[ -z "$PS1" ] && return
and then add this alias to the bottom (using the php-cli path that you determined earlier):
alias composer="/usr/bin/php-cli ~/bin/composer/composer.phar"
Finish with these commands:
source ~/.bashrc
composer --version
It depends on the host, but you probably simply can't (you can't on my shared host on Rackspace Cloud Sites - I asked them).
What you can do is set up an environment on your dev machine that roughly matches your shared host, and do all of your management through the command line locally. Then when everything is set (you've pulled in all the dependencies, updated, managed with git, etc.) you can "push" that to your shared host over (s)FTP.
I have successfully installed Composer (and Laravel) on my shared hosting with only FTP access:
Download and install PHPShell on a shared hosting
In PHPShell's config.php add a user and an alias:
php = "php -d suhosin.executor.include.whitelist=phar"
Log in to PHPShell and type: curl -sS https://getcomposer.org/installer | php
When successfully installed, run Composer: php composer.phar
You can do it that way:
Create a directory where you want to install composer (let's say /home/your_username/composer)
Go to this directory - cd /home/your_username/composer
Then run the following command:
php -r "readfile('https://getcomposer.org/installer');" | php
After that if you want to run composer, you can do it this way (in this caseyou must be in the composer's dir): php composer.phar
As a next step, you can do this:
alias composer="/home/your_username/composer/composer.phar".
And run commands like you do it normally: $ composer install
Hope that helps
I was able to install composer on HostGator's shared hosting. Logged in to SSH with Putty, right after login you should be in your home directory, which is usually /home/username, where username is your username obviously. Then ran the curl command posted by #niutech above. This downloaded the composer to my home directory and it's now accessible and working well.
SIMPLE SOLUTION (tested on Red Hat):
run command: curl -sS https://getcomposer.org/installer | php
to use it: php composer.phar
SYSTEM WIDE SOLLUTION (tested on Red Hat):
run command: mv composer.phar /usr/local/bin/composer
to use it: composer update
now you can call composer from any directory.
Source: http://www.agix.com.au/install-composer-on-centosredhat/
Most of the time you can't - depending on the host. You can contact the support team where your hosting is subscribed to, and if they confirmed that it is really not allowed, you can just set up the composer on your dev machine, and commit and push all dependencies to your live server using Git or whatever you prefer.

having problems with the shopify php api when looking for the shopify_api

PHP API using: https://github.com/sandeepshetty/shopify_api
I have PHP 5.3.27 installed
I installed Composer (by going to
the website and using their install.exe)
It mentions that
"This will download shopify_api into the
vendor/sandeepshetty/shopify_api directory."
But I do not see the folders or files anywhere on the computer.
The plugin author is saying that if you download Composer with the instructions he provided (via Terminal), then Composer will autoload those files for you. Unfortunately, though easier, simply going to the source URL for the Composer tool won't do that for you.
First, make sure you have created the composer.json file and stored it in your project directory. Then, log into your server or system via the command line (Terminal for Mac OS, Putty for Windows). Cd into your project directory, and install by entering these commands:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Composer cannot download files

I am trying to use composer on command line :
php composer.phar update
php composer.phar install
php composer.phar self-update
php composer.phar selfupdate
Whatever I do I always receive the same error message:
File could not be downloaded. Failed to open stream
I am behind a proxy. If I use a browser and type the same URLs as the ones that didn't work with command line, there is no problem.
What should I do?
If you are using composer from behind an HTTP proxy, you can use the standard http_proxy or HTTP_PROXY env vars. Simply set it to the URL of your proxy. Many operating systems already set this variable for you.
eg:
HTTP_PROXY="http://my-corp-proxy.mcdonalds" php composer.phar install
bonus points if you throw it into your bashrc if your on Linux/OS X or your environment settings for Windows.
To make it easier, you can just export the variable, then you don't have to type it all the time.
export HTTP_PROXY="http://my-corp-proxy.mcdonalds"
php composer.phar install
The right an easy way to run composer on windows under a proxy is opening the console (cmd), go to your project location and run this command:
C:\wamp\htdocs\myproject\> SET HTTP_PROXY=http://username:password#proxy.yourdomain.com:8080 && php composer.phar install
PD: You must changes parameters like: username, password, proxy.yourdomain.com and 8080 to yours
I hope this help to you
And DO NOT set https_proxy (just http_proxy)!

Categories