I'm trying to configure a PhpStorm project to utilize both remote PHP and a remote Composer. Remote being my Windows Subsystem for Linux (WSL) installation. However, when I initiate any Composer commands from PhpStorm, I get errors. And unfortunately, the errors are not very indicative of the cause or offer a link for additional details.
Errors received in my "Event Log":
12:21 PM Composer
Failed to install packages for ./composer.json.
Show in Log
And in my "Composer Log":
install --no-interaction --no-ansi
/bin/sh: 1: composer: not found
Failed to install packages for ./composer.json.
So far, I've followed the instructions located at:
https://www.jetbrains.com/help/phpstorm/how-to-use-wsl-development-environment-in-product.html
https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html
I also followed the answer at this post to set WSL as my default terminal:
How to use WSL as default terminal in WebStorm or any other JetBrains' products?
In my WSL installation, composer is located at /home/<user>/.local/bin/composer and is included in my path upon login in my /home/<user>/.profile file. And I was sure to restart PhpStorm after doing so to ensure it has the updated path. Additionally, running composer install within my project, on WSL works without issue.
I'm not sure how to determine which terminal or composer file PhpStorm is using. Either it's still trying to find and use a composer on my host Windows install (which doesn't exist) or I'm missing a path which I have to map for WSL.
Any idea how I can obtain more details as to what I have misconfigured?
I figured out my issue.
When in Settings -> PHP -> Composer, in the "Execution" section. I was already selecting "Remote Interpreter", but the "Composer executable" field requires an absolute path. I was simply supplying the name of the executable since the field is asking for the executable.
I just figured it would utilize my $PATH to resolve the executable, but this isn't using an SSH session so it wouldn't have my custom $PATH values. So it all makes sense.
Related
I'm trying to deploy my PHP (CakePHP) application through Azure DevOps and install Composer dependencies in the build step of the pipeline, using a Windows hosted agent.
The composer install is failing because common PHP extensions (namely intl and fileinfo) are unavailable to the PHP executable running in the build. Once deployed, the Web App on Azure does have these extensions. The composer web app extension is installed on the actual app service on Azure and there is a composer.phar file in the root of the repository.
The step I'm trying to run is just php composer.phar install --no-scripts --no-interaction --optimize-autoloader.
The pipeline fails with this error, but I have no idea how to access the .ini file or provide any options.
To enable extensions, verify that they are enabled in your .ini files:
- C:\tools\php\php.ini
PHP_INI_SCAN_DIR can be set, but this 'php template' from DevOps wipes out any added configuration properties when a new deploy happens. This also seems to be a totally different PHP than what the App Service actually runs. I can make a new template for config options, but the PHP extension issue seems to still be there on the build step.
If anyone knows how to simply have composer install dependencies and have them included in the build artifact (.zip file) created, I would greatly appreciate it. Thank you!
As answered in the comment by Levi Lu-MSFT, I was able to modify the PHP configuration by adding a new build task using the Command Line task and entering:
echo extension=intl >> C:\tools\php\php.ini
echo extension=fileinfo >> C:\tools\php\php.ini
Adding quotes caused an issue, but without it seems to work.
I am new to VS code. I am trying to work with PHP, but I keep getting this notification.
phpcs: Request workspace/configuration failed with message:unable to
locate phpcs. please add phpcs to your global path or use composer
dependency manager to install it in your project locally.
Intellisense doesn't work for PHP too.
I am using a Windows system. I tried to download and install Composer, but I am still getting the problem as shown in the screenshot.
]1
I have some extensions installed which are visible in the screenshot, but the issue persists.
The easiest way is to use composer to install phpcs globally and symlink the binary into your path;
Assuming you have composer installed and are using osx or linux (if not, follow instructions from here: composer) then install phpcs globally: open your terminal and type:
composer global require "squizlabs/php_codesniffer=*"
You will then need to make sure phpcs is in your path. The easiest way is to symlink into /usr/local/bin. open your terminal and type:
sudo ln -s ~/.composer/vendor/bin/phpcs /usr/local/bin/phpcs
I have developed a cs cart add on, But when I make a zip of it and try to upload it from gui it gives wrong structure data
so after little research I got that, I have to follow some steps of given in following url.
https://github.com/cscart/sdk
But after successful installation of composer, When I run the command
cscart-sdk command:name
It gives me error
cscart-sdk is not recognized as an internal or external command
I am very new to cscart add-on development
There seems to be something wrong with your composer install, please follow this tutorial (this is where cscart also relates to)
Installation - Linux / Unix / OSX#
Downloading the Composer Executable#
Composer offers a convenient installer that you can execute directly from the commandline. Feel free to download this file or review it on GitHub if you wish to know more about the inner workings of the installer. The source is plain PHP.
There are in short, two ways to install Composer. Locally as part of your project, or globally as a system wide executable.
Locally#
Installing Composer locally is a matter of just running the installer in your project directory. See the Download page for instructions.
The installer will just check a few PHP settings and then download composer.phar to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
Now just run php composer.phar in order to run Composer.
You can install Composer to a specific directory by using the --install-dir option and additionally (re)name it as well using the --filename option. When running the installer when following the Download page instructions add the following parameters:
php composer-setup.php --install-dir=bin --filename=composer
Now just run php bin/composer in order to run Composer.
Globally#
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH, you can access it globally. On unixy systems you can even make it executable and invoke it without directly using the php interpreter.
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, you may need to run it again with sudo.
Note: On some versions of OSX the /usr directory does not exist by default. If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding: mkdir -p /usr/local/bin.
Note: For information on changing your PATH, please read the Wikipedia article and/or use Google.
Now just run composer in order to run Composer instead of php composer.phar.
I am new to Laravel, I have installed the Laravel on my localhost using
WAMP server but I am getting an error after all steps.
The errors are:
( ! ) Warning: require(C:\wamp\www\laravel/../bootstrap/autoload.php): failed to open stream: No such file or directory in C:\wamp\www\laravel\index.php on line 21
( ! ) Fatal error: require(): Failed opening required 'C:\wamp\www\laravel/../bootstrap/autoload.php' (include_path='.;C:\php\pear') in C:\wamp\www\laravel\index.php on line 21
I have used below link for Laravel installation
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
I have tried to debug the issue but haven't found success in the installation.
Please let me know what is missing in installation.
You need to install Composer, open up the command prompt and cd to your directory (or hold Shift while right-clicking on your directory and clicking Open command window here) and there run composer install.
You can simplify the Laravel installation with Composers create-project command.
composer create-project laravel/laravel path
Laravel dependencies are not installed yet. That is why it is giving you this error.
https://getcomposer.org/download/
Go to this link and download composer if you haven't already.
Move the composer file to /usr/bin and rename it to just composer.
Go into the root directory of your laravel application. And run:
composer update
This will install and update all required dependencies.
In case you are on windows, which is less likely, but if you are, just download and install composer via the installer and issue the same command in you project's root directory.
Composer is PHP's dependency manager.
In the root directory of your laravel installation you will find a composer.json file. It contains the list of all your project's dependencies. If you ever need to install a package in your project, it becomes very easy. You just have to edit the composer.json file and let it know which package you need. Issuing composer update will install new package listings and update all existing ones.
just to be clear I'm not big fan of wamp.
I've just took quick look at the
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
and I suppose laravel framework is not going to work best with point 11 to 14 modifications.
Baseline for laravel to work is you need to http serve /public folder in a properly configured environment (after composer install and create-project as described earlier).
If you want to take full advantage of laravel you need to often cli `php or composer (at least)` efficiently.
While using laravel I suggest installing PHP and MYSQL yourself from scratch (it really takes few minutes) and using convenient IDE (like PHPSTORM for example).
Nowadays PHP has builtin http server, so you don't need any http server in your dev environment.
So in Windows:
Install PHP and enable required libraries in php.ini
Install and configure local mysql server (easiest way installing via MySQL installer)
Start development server by invoking php.exe -S localhost:80 -t "absolute-path-to-your-laravel-installation\public" like for example C:\htdocs\laravel\public via commandLine
Enter url in your favorite browser http://localhost
Hope that will help to get you started.
I'm using Bluehost and do have access to SSH, thankfully. I've also set my PHP to 5.4 in the Control Panel settings. Now, here's the two big questions that I can't seem to grasp: how do I install Composer and furthermore, after installing Composer, how do I get the dependencies included?
In this case, I am attempting to use the official Tumblr PHP Library, which has dependencies -- all of which can be found on Packagist.
I've referred to this question in which the OP is using HostGator. I have attempted to install Composer in a similar fashion and have done so with seemingly successful results. The issue, however, is that I don't know where to install it on Bluehost so I now have Composer installed in several random places on the server simply because I don't know how to navigate to find where to put it in this shared space.
I know this is the issue (i.e. it's installed in the wrong place) because when I use the composer phar files and syntax to install the packages, I get errors saying the commands don't exist.
I really hate asking for hand-holding assistance, but if someone could walk me through the proper installation of Composer on a shared space and the proper installation of a Composer package from Packagist on the same shared space, it would be much appreciated. I've dug through the Composer documentation and can't seem to find a proper guide -- if one can even exist -- for this case. At this point, I'm wondering if it's going to be different for every web host.
Once you install composer as mentioned by KLVTZ. In the bluehost environment, use the php-cli instead of php.
php-cli composer.phar install
When installing composer, the biggest problem I ran into was that Bluehost's command line php was 5.2 and composer needs 5.3+.
Fortunately, Bluehost does give you access to 5.4. You can find it at
/ramdisk/php/54/bin/php54-cli
I ended up setting up an alias to call composer.phar using the above php command and it's worked great. You can see more details on how to install composer on bluehost.
You should probably not use Composer on the remote host, but instead install it on the local machine that is used to upload your project to Bluehost. There you can manage all the stuff that is needed to fetch the dependencies, which might include having the ZIP extension enabled or having a ZIP program available, having GIT or Mercurial installed if you have to grab a version from a branch, and so on.
All these dependencies of using Composer might not be available on that remote host, and frankly: You really do not want to install these development tools on a production machine anyway, I think. Any software that potentially helps an attacker shouldn't be present if it can be avoided.
The issue, however, is that I don't know where to install it on Bluehost...
In order to fix this problem, you need to figure out where exactly your project folder is. Composer needs to be installed in that folder. If you have access to a UNIX shell, I recommend that you change your directory to that project folder
cd $_SERVER['DOCUMENT_ROOT']/project_folder/
Generally, your remote server will follow the same file directory tree as that on your local machine. However, if you are unsure as to how your file structure may be organized, you can always print working directory of your local machine:
pwd
After you have successfully located the correct file path on your shared space, simply install composer:
curl -sS https://getcomposer.org/installer | php
This will report back something like:
All settings correct for using Composer
Downloading...
Composer successfully installed to: /var/www/my_project/composer.phar
Use it: php composer.phar
You now have access to your composer.phar in your project. Let me know if you need any further help.
One problem on Bluehost is that the php command on Bluehost does not execute php-cli. So I "bypass" that by having my own php script earlier in the PATH and then forwarding the arguments to php-cli. In the same process I made script named composer which calls php-cli composer.phar directly.
So, this setup has worked for me on Bluehost:
In ~/bin I have the composer.phar and two bash scripts called php and composer. In ~/.bash_profile I have prepended ~/bin to my PATH.
~/bin/php looks as follows:
#!/bin/bash
php-cli "$#"
~/bin/composerlooks as follows:
#!/bin/bash
php-cli ~/bin/composer.phar "$#"
And the additions to ~/.bash_profile are these:
PATH=$HOME/bin:$PATH
PATH=$PATH:$HOME/.composer/vendor/bin
export PATH
(I have also added ~/.composer/vendor/bin as can be seen, this is handy for global access for some composed applications (for me that is laravel)).
Remember to source ~/.bash_profile. (Or reconnect)
I think you should do something like this.
In console
echo $PATH
Use one of these pathes
mv composer.phar {selected path}/composer
chmod +x {selected path}/composer
Now you can simply call composer everywhere
If you have composer installed in your root directory (under public_html), might be something related to PHP version. As Bluehost when chosing PHP version "Be aware that this only modifies your ~/public_html/php.ini file. If you choose to use PHP 5.4, you'll want to make sure your crons use "/usr/php/54/usr/bin/php" instead, as otherwise it will use PHP 5.2."
So you can try with the command
/usr/php/54/usr/bin/php-cli composer.phar install