How to install two composer in one windows system? - windows

How to install two composer in one windows system? (how to use difference composer in one windows system)

If you're using the windows installer only, IIRC you can't as it ships with the precondition to install under the canonical composer name.
However if you download the phar file, you just need to use the phar file of the version you would like to execute. This works independently to using the windows installer - both with and without it.
This has also the benefit that you can specify the PHP executable you would like to run composer.phar with.
c:\> c:\my\php.exe c:\my\composer-2.2.10.phar --version
This is basically what the Composer manual means where-ever it writes php composer.phar ....
You replace php with the PHP executable you would like to use and composer.phar with the composer phar you would like to use.
The windows setup installer is just installing the latest with the PHP version on your system under the canonical name composer. But instead you can create your own composer.bat.
You can then also create two such files for the different versions, e.g. composer-blue.bat and composer-red.bat.
This technique should be compatible to have next to composer with the windows setup installer, so you can use it to install one version you manage with the setup and zero up to N versions you manage yourself with the phar files.
Composer homepage lists all composer.phar files, see https://getcomposer.org/download/ and scroll down to "Manual Downloads" section.
A command-line utility like wget which also runs on Windows can greatly help you to streamline your process downloading the composer version of your choice under the file-name you'd like to have.
There is a Wikibook available on Windows Batch Scripting.

for window do the following steps:
one -> (create composer1 directory in C:\composer_path)
two -> (copy three file in composer directory to composer1 directory)
three -> (set path composer1 to environment variable)
four -> (run composer1 self-update --1 in cmd) because Convert to version 1.0.0
five -> (test versions composer)
and Done! ^_^
you can see two version of composer installed in one windows system.

Related

Why is my composer command not working in subdirectories on a 1and1 webhosting server?

I'm in the process of building a TYPO3 website on a webserver hosted by 1and1 ionos. I need to install TYPO3 via composer, so I installed composer to this webserver first. It seemed to work fine and I was able to do a composer reuqire to install TYPO3 to a new directory (named: typo3-composer) within the root of the server.
But for some reason I have two problems now:
Within the root directory of my server I cannot run the "composer xx" command. It only works using the prefix "php composer xx"
In my subdirectory typo3-composer (the one I installed TYPO3 into) I cannot run ANY composer command. Terminal simply says command composer not found.
What I did so far:
1. Install composer
curl -sS https://getcomposer.org/installer | /usr/bin/php8.0-cli
2.Start composer
/usr/bin/php8.0-cli composer.phar
3.Rename file
mv composer.phar composer
4.Tried to move the file to any directory (usr/local/bin) of the $PATHvariable to make composer globally accessible. This failed because all of those directories are read-only. So i made the file executable
chmod +x composer
5.And added the current path to the system's $PATH variable
export PATH=$PATH:$PWD
I'm pretty sure this is a very basic logial mistake. Where do I have to execute the composer install command and where do I have to put the composer file so that I can use the command from every directory?
(PS: I did set the PHP Version of the Shell to php 8.0 already so I don't have to use /usr/bin/php8.0-cli all the time)
Thanks for your well formulated question which I'd like to answer the following:
If you would like to (really) execute Composer on the remote host1, you already have the answer albeit you might not be aware of it. To quote from your very own question:
It only works using the prefix "php composer xx"
This is fine and how PHP works on the command-line. However as you have noticed it depends on the directory you're in (the working direcory). Not for the command (php) but for the file you command php(1) to execute: "composer".
Some more context if it helps: The first operand of the php command you entered, "composer", is the path to the file you want php(1) to execute.
So when:
user#host:~$ php composer info
...
works and you then change the directory and it doesn't any longer:
user#host:~$ cd typo3-composer
user#host:~/typo3-composer$ php composer info
Could not open input file: composer
user#host:~/typo3-composer$ echo $?
1
then replacing composer with the actual path of it should work:
user#host:~/typo3-composer$ php ../composer info
...
before actually running php(1), you can also make use of the file(1) command to check first if a file exists and of what type it is:
Not existing file:
user#host:~/typo3-composer$ file composer
composer: cannot open `composer' (No such file or directory)
Existing "composer" file (with executable bits set):
user#host:~/typo3-composer$ file ../composer
../composer: a /usr/bin/env php script executable (binary data)
Composer phar (even with no executable bits):
user#host:~/typo3-composer$ file ../composer
../composer: a /usr/bin/env php script executable (binary data)
Composer is just a PHP file (sort-of, it is a PHP archive "phar") and the idiom to execute it under the name composer is not really necessary. The path (absolute or relative to your currend working directory "PWD"2) suffices. If you take a look in the Composer documentation for example, you find the following idiom:
php composer.phar <options>|<operands>...
TLDR: Composer works regardless how you invoke it, be it composer, php composer.phar or similar. The php(1) command only needs a pathname of the PHP file to execute, be it composer.phar or one of the typo3 command-line scripts (to give a different example).
As user Nico Haase already has pointed out, there is no inherent requirement to execute composer(1) on the remote host.
Composer interacts with the wide-area-network (WAN, also: WWW, internet) to download files and applies the result to the working directory (project directory), more specifically the vendor-dir (vendor directory, "vendor" relative to the composer.json configuration file by default).
You normally then afterwards deploy that (local) project to the remote host. There is no requirement at all to do the dependency resolution on the remote host, quite the opposite: bring the work near to yourself so that you can much faster deal with any problems that may arise and make the deployment step dead simple (e.g. a single, simple transaction). Remote machines go offline, network connection may get lost in the middle and you may also need to (or want to) fully replace the remote host occasionally. All you should need to do is to re-deploy the project, not configuring remote systems and run commands there interactively. Life is too short for that.
Now the Typo3 project might have thought otherwise (which would not be very user-friendly if you allow me the comment, but I know the typo3 folks are user-friendly for real) then you may go through additional hurdles, however those are less related to Composer (and how you invoke it) but more to Typo3 (then, if at all). But, as you don't present Typo3 as an issue in your question, I'm pretty sure you can just do the "Composer work" locally in your own shell which has the benefit that you can configure Composer and how you invoke it to your liking without the requirement to do this only short and half at best on every remote host you may come in contact with.
PWD
This variable shall represent an absolute pathname of the current working directory. It shall not contain any components that are dot or dot-dot. The value is set by the cd utility, and by the sh utility during initialization. [from]

Integrating Vagrant and PHPStorm with Composer/PHPCS using Remote Interpreter via Shared Folders?

I'm using a Vagrant VM created by Puphpet, running Ubuntu 14.04 for the purpose of developing a Wordpress site. I use Composer to manage PHP dependencies, and Composer is installed automatically as a system service via Puphpet, so there is no .phar file, just an executable Composer file in /usr/local/bin/composer.
I also use PHPStorm as my main IDE, and love its Remote Interpreter feature. So far, PHPUnit is the only feature that supports it, as Composer and PHP Codesniffer requires having a local PHP interpreter installed in order to be used. This kind of defeats the purpose of the Composer/PHP Codesniffer tools within PHPStorm when used with Vagrant. Jetbrains claims they have no plans to add this feature in the near future.
Which leads me to my question- Would it be possible to set up a shared folder to the PHP executable file in my VM, and use that as my Remote Interpreter in the Composer Settings window?
Could I also do the same to my PHPCS executable file path in the Code Sniffer settings panel with PHPStorm?
The only one I wouldn't be able to set up a Shared Folder to is the composer.phar file which is needed to run the Composer tool within PHPStorm, because there is no composer.phar file within my VM, as its just an executable in /usr/local/bin/composer as I described earlier. So would the solution be to download a composer.phar file to somewhere within my host directory? Will this interfere the Composer install on the VM?
*Update: As Sven has explained to me, the Composer file in /usr/local/bin/composer is the composer.phar file. I kind of understood this, but still am not sure if a. PHPStorm will recognize it as such, and b. if creating a shared folder will even work.
I added images of the settings panels so you can understand what I'm talking about.
Thanks, let me know if you need anymore info.

what is phpmd and how to use it?

I have Ubuntu 14.04 + Sublime text 3 and installed phpcs packages
additionalty I have installed phpcs and php-cs-fixer on my system
From this blog
I have found that phpmd (PHP Mess Detector) is also a required library, so installed phpmd as per given instructions on official php md page using alternative method From the github repository everything was finished.
:~/phpmd$ curl -s http://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /home/keshav/phpmd/composer.phar
Use it: php composer.phar
but now when I write on terminal
phpmd /opt/lampp/htdocs/myproject, myfile.php
phpmd: command not found
There is phpmd folder on Home directory and everything without any error.
I have local project on core PHP create composer.json in project folder as per suggested on github .
Please tell me what means by
Then install Composer in your project (or download the composer.phar directly):
I think the problem is you've installed phpmd in a local directory, but you're trying to use it as if it was installed globally.
Installation instruction on the referenced sites can't really be made any clearer. Since you've already installed phpcs and php-cs-fixer, and those work for you, just follow similar instructions for phpmd. These are all PHP projects and are installed in a similar way.
Anyway, to use phpmd as a global command you have several options.
Github
Clone the github repository just like you did and add the phpmd bin directory to your PATH variable.
Global composer installation
Use the composer global command to install phpmd globally. You will also need to make sure that composer's bin directory is in the PATH. By default it's ~/.composer/vendor/bin.
composer global require phpmd/phpmd
This command will install phpmd globally, and as soon as ~/.composer/vendor/bin is in your PATH you'll be able to call it by simply invoking phpmd.
It's very well explained in composer's documentation: https://getcomposer.org/doc/03-cli.md#global
Download the phar archive
This is the simplest thing you can do. Simply go the phpmd releases, choose the latest and download the phar archive.
Put the phar file to whatever place you'd like. Just remember that it needs to be in your PATH. You can also rename it, to skip the .phar extension.
For example:
wget http://static.phpmd.org/php/2.1.3/phpmd.phar
sudo mv phpmd.phar /usr/bin/phpmd
sudo chmod +x /usr/bin/phpmd
Docker container
First, fetch the docker image with static analysis tools for PHP:
docker pull jakzal/phpqa
One of the tools provided by the image is phpmd. The command below will run phpmd in a docker container and mount the current working directory as a /project.
docker run -it --rm -v $(pwd):/project -w /project jakzal/phpqa \
phpmd src text cleancode,codesize,controversial,design,naming,unusedcode
When you use the composer-based install, it gets installed into the ./bin directory within the ./vendors directory. So for me, relative to my project's root directory, it was here:
./vendor/bin/phpmd
And I was able to run it from my project's root by running ./vendor/bin/phpmd . text codesize. (I'm not getting any useful output yet, but another issue)

How to install Laravel via installer?

In Laravel documentation, it explained one short paragraph on how to use installer to install Laravel.
First, download the Laravel installer PHAR archive. For convenience, rename the file to laravel and move it to /usr/local/bin. Once installed, the simple laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog would create a directory named blog containing a fresh Laravel installation with all dependencies installed. This method of installation is much faster than installing via Composer.
I am a Windows 7 user. After download the laravel.phar file, where should I store the file? I don't think there is any /usr/local/bin directory on Windows 7. How can I get the laravel command to be able to use in command window?
Install laravel 5.2 via Laravel Installer in windows 7
Steps:
Please make sure you have installed composer into your computer
Open command prompt
$ composer global require “laravel/installer”
C:\xampp\htdocs> laravel new mylaravel
Youtube video guide:
http://www.pranms.com/how-to-install-laravel-5-2-via-laravel-installer-in-windows-7/
The laravel installer needs to be in your PATH (no matter which Operating system).
In Unix based systems, /usr/local/bin is in your PATH by default.
On Windows, you can add a folder to your PATH by doing like this:
Start the System Control Panel applet (Start - Settings - Control Panel - System).
Select the Advanced tab.
Click the Environment Variables button.
Under System Variables, select Path, then click Edit.
From http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path
It's a lot easier to install using Composer. Download the Windows Composer installer from the Composer Website and run it. Once it's installed you can run from the command line:
composer create-project laravel/laravel your-project-name
This will create the folder your-project-name and install Laravel in it. The advantage of using Composer it that it makes adding other packages to Laravel really easy.

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

Resources