difference between composer and composer.phar - composer-php

What is the difference between composer and composer.phar?
Example:
composer install
composer.phar install
Is there a reason why I keep seeing code writen using composer.phar all the time when composer does the same?

There is no difference - composer.phar is the executable and composer can be an alias or symlink for it, depending on the way you've installed composer. As rob006 pointed out, there can be multiple ways to install composer: the official documentation at https://getcomposer.org/doc/00-intro.md#globally recommends to move the downloaded PHAR file to /usr/local/bin/composer which will make it callable through composer for all users of your system.
If you would move the file to another destination, like /usr/local/bin/composer.phar, the same composer binary would be available under that different command composer.phar.
And finally, if you would not have the chance to install composer globally, you could put it under either name in any local place

Related

composer.phar: download new version or doing self-update?

Does it make any difference between updating by composer.phar self-update and just replacing composer.phar with a newer version (e.g. with curl -sS https://getcomposer.org/installer | php)?
I'm asking this since composer.phar self-update makes some problems and I thougt then I will just download a new version. But I'm also wondering if it's just about replacing one single file, why is self-update implemented as well? What is the benefit of using this routine?
The process is different, but the result is the same. Using the most recent composer phar file.
The benefits are in easier access. To update, I just type composer like I always do when install/update/require new packages, then add self-update.
Also when I forget the command, just run composer and command list is printed.
One more reason is it's common command in PHAR file ecosystem. PHPUnit, PhpCsFixer and many other have the same command.

Getting Error in installation of yii2 advance template

I'm new to Yii2, I'm trying to install yii2 application advanced template.
I did follow these steps:
1 - Download yii2-app-advanced zip file from https://github.com/yiisoft/yii2-app-advanced
Follow GETTING STARTED guide:
My vendor directory Show Empty.
Please help, thanks in advance
Installing via Composer
If you do not already have Composer installed, you may do so by following the instructions at getcomposer.org. On Linux and Mac OS X, you'll run the following commands:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
On Windows, you'll download and run Composer-Setup.exe.
Please refer to the Composer Documentation if you encounter any problems or want to learn more about Composer usage.
If you had Composer already installed before, make sure you use an up to date version. You can update Composer by running composer self-update.
With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:
composer global require "fxp/composer-asset-plugin:~1.0.3"
composer create-project --prefer-dist yiisoft/yii2-app-advanced basic
The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs Yii in a directory named basic. You can choose a different directory name if you want.
Note: During the installation Composer may ask for your Github login credentials. This is normal because Composer needs to get enough API rate-limit to retrieve the dependent package information from Github. For more details, please refer to the Composer documentation.
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced basic
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %>composer.bat*
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate
Refrence
use composer cos you need composer in future too!
and after unzip the advance project in www or htdocs you should navigate to your project with cmd or terminal and type yii migrate after that again type composer update

Composer how to specify install directory

Hi I've recently downloaded Laravel as a PHP framework, I've installed composer and have got that working, I've got it to create my project as per the Laravel website
composer create-project laravel/laravel --prefer-dist
However when I use the above line this installs my project in the c:\users\guti directory however I want it to be installed in c:\xampp\htdocs.
I've seen another question on stackoverflow and it talks about amending the composer.json file but I'm not sure whether this is the route I should be taking as I've done a computer search for this file and this file exists as part of the laravel framework so does it make sense to amend this file?
Any composer experts on hand to point me in the right direction?
composer create-project laravel/laravel .
Installs in your current directory =)
You should specify your destination directory where you want to create the project, from the command prompt, type cd C:\xampp\htdocs then press enter. After that, type following code on the command prompt and press enter
composer create-project laravel/laravel my-laravel-project
Here my-laravel-project will be your project folder.
The composer.json file is used to setup some configurations (for Dependency management) during installation of the package via packagist.
Visit getcomposer.org for more information.
Whenever
composer create-project laravel/laravel .
Doesn't work properly for whatever reason, I just
laravel new temp
And then move the contents of the new application into the folder I do want ; )
I needed to do this myself. In the directory I wanted it installed, I did:
laravel new --force .
And it seems to be working well so far.
This works for me on Ubuntu 20.04, Composer version 2.1.6:
cd your-directory
composer create-project laravel/laravel ./
TL;DR
composer create-project --prefer-dist laravel/laravel directory-name
Move files to preferred folder if needed (e.g. to ../)
Why don't laravel new /.?
laravel new project-name not always works good on different systems, so you need to edit PATH variable multiple times to add laravel command to cli (at least on OSX it's not that easy as on Ubuntu).
composer create-project --prefer-dist . may not work because of not empty directory (e.g. in JetBrains IDE's, which creates folder .idea/ which doesn't shows in IDE's 'project' view, only on 'project files'). Exception message looks like
[InvalidArgumentException]
Project directory ./ is not empty.
So, if you know what you doing, do as you wish, on the other way, especially if you want as few problems as possible, do the steps from the top lines of this answer.
P.S. I'm speaking english not as good as i want to do, so, anyone, feel free to correct me.

Laravel 4 Installation Problems on WAMP/Windows

First,I use wamp on my Window7.I open php-openssl,and I git pull the laravel from github.com,and then I put laravel on my d:/wamp/www/, I change the c:/windows/system32.But when I open the url
http://localhost/laravel/public
I see this question.
I am a newbie on laravel,and without install on Ubuntu.Where is my wrong, without no pear,or something else? Thank you!
You need to run composer install in a command prompt.
If you do not have composer, download the phar file from their website.
Place the file you just downloaded into the laravel directory.
Then, make sure that the absolute path to php.exe is added to your PATH environment variable.
Then, you can hold down shift, and right click anywhere inside the laravel directory, and open up a command prompt window. Then, run php composer.phar install. The process may take some time, depending on the speed of your internet connection.
Instead of using the above method, you can download the Composer installer for Windows, install it, and just run composer install.
Note that you only need to do this in order to put the Laravel components together. You do not need to run it on a live server.
Please consult the Laravel Docs for installation and other instructions: http://laravel.com/docs
Try This :
Installing Laravel 4 on WAMP
1. Enable OpenSSL
OpenSSL must be enabled in the PHP configuration.
Edit php.ini in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
Note: This is not the php.ini in C:\wamp\bin\apache\Apache2.4.4\bin.
Find the following line and remove the semicolon save it:
;extension=php_openssl.dll changed to extension=php_openssl.dll
2. Install Composer
(i).Download the Composer Windows installer from getcomposer.org.
(ii). Run the installer.
(iii). When it asks for the location of php.exe, point it to the executable in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
(iv). Finish the installation.
(v). Open a command-line interface (cmd) and type:
composer
It should return a list of options. If you get an error, restart your computer and try again.
Composer has now been installed and added to your PATH environment variable. This means you can run it from any directory using the command-line interface.
Now we need to install Composer. This is a dependency manager that will download the latest release of Laravel and specific versions of Laravel’s dependencies, such as Doctrine and Symfony.
3.Install Laravel
Now that Composer has been installed, Composer can download and install Laravel onto your system.
(i). Open a command-line interface (cmd).
(ii). Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we’ll use C:\wamp\www\laravel
(iii). Instruct Composer to install Laravel into a project directory. we use project name myproject.
composer create-project laravel/laravel myproject --prefer-dist
Note: This will install Laravel in a subdirectory myproject of the current working directory.
Three type of installation to be completed
Now your project was running directory like
C:\wamp\www\laravel\myproject\public\
After completed put tick mark and increase the point....
Do php composer.phar dump-autoload or php artisan dump-autoload

Satisfy Composer platform dependency using alternative path

How can I satisfy a Composer platform package dependency with an alternative path? I have a package that depends on php >=5.4, but my stock PHP is 5.3 and I have a separately maintained PHP 5.4 installation under the executable name of php54. Any way to make Composer aware of it?
You can run composer through your php54 executable. Either call it explicitly php54 composer.phar ... but that is painful if you have composer installed globally. In that case you're probably better off doing a shell script called composer that will call the phar file with php54 or register a bash alias for it.

Resources