Laravel Installation/Configuration - Command Not Found - php

Trying to install Laravel on Ubuntu Server 14.04. After installing PHP 7 I enter:
curl -sS https://getcomposer.org/installer | php
I get: Composer successfully installed to: /home/ubuntu/composer.phar
sudo mv composer.phar /usr/local/bin/composer
composer
Works fine
composer global require "laravel/installer"
I get:
nano ~/.bashrc
I include this export PATH="~/.composer/vendor/bin:$PATH" at the very bottom.
sudo service apache2 restart
Restart it
laravel
I get: "laravel: command not found"
Why does it not understand the command laravel?

I'm writing this answer for all the future Google searchers. I had a similar issue and I solved it in the following way:
First run:
sudo apt-get install zip unzip php7.0-zip
Then, edit your ~/.bashrc file and append the following line:
export PATH="$PATH:$HOME/.composer/vendor/bin"
or
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
Which one is yours, depends on the line composer printed out during installation of laravel, followed by /vendor/bin. In my case (and in the case of the question), this was $HOME/.config/composer, so I had to do it the second way:
Don't forget to call
source ~/.bashrc
at the end. Enjoy Laravel!

From your screenshot, I can see that there may be a chance the laravel packages were not installed correctly as you don't have zip and unzip installed on your system.
Run the following command to install these first and then try again to install laravel installer:
sudo apt-get install zip unzip
Regarding the export PATH use $HOME instead of the tilde ~ sign. Hope this will solve your problem. Seems like a path error.
export PATH="$PATH:$HOME/.composer/vendor/bin"

Related

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have php7.3 and symfony2.8 When I try to create the classes with the console I get this error:
[Symfony\Component\Debug\Exception\ContextErrorException]Warning:
"continue" targeting switch is equivalent to "break". Did you mean to
use "continue 2"?
I've got same problem and got this error too, but in my case this error shows when i'm trying to run composer install or composer update.
and i solve this issue by running composer self-update. it works on my project.
Maybe your composer is outdated.
Below are the steps to get rid of the error.
Note: For Windows professionals, Only Step2 and Step3 is needed and done.
Step1
Remove the composer:
sudo apt-get remove composer
Step2
Download the composer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Step3
Run composer-setup.php file
php composer-setup.php
Step4
Finally move the composer:
sudo mv composer.phar /usr/local/bin/composer
Your composer should be updated now. To check it run command:
composer
You can remove the downloaded composer by php command
php -r "unlink('composer-setup.php');"
The issue looks to me to be a backward incompatibility with PHP 7.3 for the continue keyword in Switch statements. Take a look at the "Continue Targeting Switch issues Warning" section in Backward Incompatible Changes.
I ran into the same issue with Symfony 3.3 using PHP 7.3 and downgrading to PHP 7.2 resolved the warning.
I upgraded to PHP 7.3, and None of these worked for me before I used,
sudo wget https://getcomposer.org/download/1.8.0/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer
It's just the version dependency. PHP 7.3
and composer update worked like a charm!
I changed continue to continue 2 on line 1579 in shortcodeComon.php and it fixed my problem
if(trim($custom_link[$i]) == ""){
continue;
}
Change to:
if(trim($custom_link[$i]) == ""){
continue 2;
}
composer self-update
composer install
Now, it should works
In my case php was upgraded from php7.2.22 to php7.3.9.
so had to downgrade cli php as composer is run on terminal
//checked php version
php -v //was 7.3.9
//changed cli version back to 7.2
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
//checked php version
php -v //was 7.2.22
additional info if you are using apache remember to keep both cli and apache in same version. in my case i had to downgrade
//changed web version back to 7.2
sudo a2dismod php7.3
sudo a2enmod php7.2
sudo service apache2 restart
This will work with other versions. so feel free to switch between versions. just replace the version numbers appropriately
Windows 10 Professional
PHP 7.3.1
I ran these commands to fix the problem on my desktop
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
that seems to be an issue with php7.3, I guess.
If you have different version installed on your system then you could use this:
php7.1 /usr/bin/composer update // or wherever your composer is
it worked for me
Or download composer.phar from site: "https://getcomposer.org/download/" (manual download), and use command:
php composer.phar require your/package
I think it's a version problem, you just have to uninstall the old version of composer, then do a new installation of its new version.
apt remove composer
and follow the steps:
download the composer from its official release site by making use of the following command.
wget https://getcomposer.org/download/1.6.3/composer.phar
Before you proceed with the installation, you should rename before you install and make it an executable file.
mv composer.phar composer
chmod +x composer
Now install the package by making use the following command.
./composer
The composer has been successfully installed now, make it access globally using the following command.
for Ubuntu 16
mv composer /usr/bin/
for Ubuntu 18
mv composer /usr/local/bin/
I've got the same problem when I run composer install
I solve it by doing in composer directory php composer.phar self-update and then in my project directory composer update
after upgrading my xampp from 7.2.0 to 7.3.0 i face this issue but after unistall composer.exe and install latest composer.exe from composer.org than issue resolved
I had to upgrade doctrine/orm:
composer update doctrine/orm
Updating doctrine/orm (v2.5.13 => v2.6.6)
On debian 9 php7.3 the answer above pasted below worked perfectly.
sudo wget https://getcomposer.org/download/1.8.0/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer
I had the same issue. but fixed it by downloading composer & installing it from scratch.
If your code cannot be updated on some reason, just change your switch ... continue to switch ... break, as in previous versions of PHP it was meant to work this way.
#aimme's answer should be accepted!
I would extend his answer with #david-baucum's comment because his explanation is clear!
I would also extend his answer that you can run multiple PHP versions at the same time using ppa:ondrej/php.
Then you don't need to change the PHP version simple call the composer like this:
/usr/bin/php7.2 /usr/local/bin/composer install
Sorry for the "diggy up", but i just encoured this issue with an symfony3.8 project deploiement on shared hosting (php 7.3.18)...
I solved this issue by set the php memory limit in the command line options, a stuff like this:
php -dmemory_limit=-1 /path/to/the/executable
In order to eliminate this error, you have to fo to the wp-config file and add these lines of code
define('WP_DEBUG_DISPLAY', false);
#ini_set('display_errors',0);

How do I uninstall a PHP module?

I bumped into this bit of instructions while installing an addon for a PHP framework:
Make sure you don't have the PHP module installed. This is a Debian/Ubuntu example:
sudo apt-get purge php5-geoip
I am working on Windows PC with a Virtual Machine running Laravel Homsetead. I am using Git Bash command window. When I enter the above command I get:
bash: sudo: command not found
If I remember correctly, sudo is an Apple-related command so I tried dropping it like this:
apt-get purge php5-geoip
but I get
bash: apt-get: command not found
What command do I need to use to purge php5-geoip?
EDIT: echo $PATH gives out:
$ echo $PATH
/c/Users/Arthur/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/
bin:/c/Users/Arthur/bin:/c/ProgramData/Oracle/Java/javapath:/c/Windows/system32:
/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/
c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x86:/c/Program Files (x86)/Intel/
OpenCL SDK/2.0/bin/x64:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c
/Program Files/MATLAB/MATLAB Production Server/R2015a/runtime/win64:/c/Program F
iles/MATLAB/MATLAB Production Server/R2015a/bin:/c/Program Files/MATLAB/MATLAB P
roduction Server/R2015a/polyspace/bin:/c/Program Files (x86)/Skype/Phone:/c/PHP:
/c/ProgramData/ComposerSetup/bin:/c/Users/Arthur/AppData/Roaming/Composer/vendor
/bin:/c/HashiCorp/Vagrant/bin:/c/Program Files/nodejs:/c/Users/Arthur/AppData/Ro
aming/npm:/usr/bin/vendor_perl:/usr/bin/core_perl

Running Composer returns: "Could not open input file: composer.phar"

I am new to symfony2 and reading symblog. In third chapter while trying with data-fixtures I tried the command:
php composer.phar update
but I got the error:
Could not open input file: composer.phar
So I googled a little and tried
php composer.phar install
but still getting the same error. So please guide how to deal with this composer to install new extentions or bundles like data-fixtures in symfony2 using wamp.
If you followed instructions like these:
https://getcomposer.org/doc/00-intro.md
Which tell you to do the following:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
Then it's likely that you, like me, ran those commands and didn't read the next part of the page telling you to stop referring to composer.phar by its full name and abbreviate it as an executable (that you just renamed with the mv command). So this:
$ php composer.phar update friendsofsymfony/elastica-bundle
Becomes this:
$ composer update friendsofsymfony/elastica-bundle
I had the same problem on Windows and used a different solution. I used the Composer_Setup.exe installation file supplied by the composer website and it does a global install.
After installing, make sure your PATH variable points to the directory where composer.phar is stored. This is usually C:\ProgramData\ComposerSetup\bin (ProgramData might be a hidden directory). It goes without saying, but also be sure that the PHP executable is also in your PATH variable.
You can then simply call
composer install
instead of
php composer.phar install
Background
It is helpful to know that there are two ways to install (and use) Composer: locally as a file in your project directory, or globally as a system-wide executable.
Installing Composer locally simply means that you are downloading a file (composer.phar - which is a PHP Archive) into your project directory. You will have to download it for every project that requires Composer.
Like a regular PHP file that you want to execute on the command line, you will have to run it with PHP:
php composer.phar update
Which basically tells the php executable to run the file composer.phar with update as argument.
However, if you install it globally, you can make composer itself executable, so you can call it without php (and don't have to download it for every project). In other words, you can use composer like this:
composer update
Since you are executing php composer.phar update, and you are getting the error Could not open input file: composer.phar, you probably don't have composer.phar in your current directory.
Solution
If you have Composer installed globally, simply run composer update instead of php composer.phar update.
If you don't have Composer installed yet, download the PHAR using the following command:
curl -sS https://getcomposer.org/installer | php
This will download the installer and run it using php. The installer will download the actual Composer PHAR to your current working directory, and make it executable.
To install Composer globally (I recommend this), copy the file to a location in your PATH. The exact location differs per operating system and setup, see https://getcomposer.org/doc/00-intro.md#globally for more information.
Personally, I prefer to install Composer in my home directory so I don't need sudo to install or update the composer executable (which can be a security risk). As I'm on Linux, I use the following command:
mv composer.phar ~/.local/bin/composer
If anyone else came this low on the page and still didn't find a working answer (like I did), use this:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer.phar
$ alias composer='/usr/local/bin/composer.phar'
$ composer --version
et voila! A working composer :-)
To solve this issue the first thing you need to do is to get the last version of composer :
curl -sS https://getcomposer.org/installer | php
I recommend you to move the composer.phar file to a global “bin” directoy, in my case (OS X) the path is:
mv composer.phar /usr/local/bin/composer.phar
than you need to create an alias file for an easy access
alias composer='/usr/local/bin/composer.phar'
If everything is ok, now it is time to verify our Composer version:
composer --version
Let's make composer great again.
I found this worked as I did not have curl installed. On Windows 8 with XAMPP installed. It will add it to your local build I use .gitignore to avoid the repo
php -r "readfile('https://getcomposer.org/installer');" | php
I got it from here: https://getcomposer.org/download/
This worked for me:
composer install
Without
php composer install
Run the following in command line:
curl -sS https://getcomposer.org/installer | php
Yesterday I was trying to install Yii2 framework on Windows 10 and I have same problem(Could not open input file: composer.phar) running this command:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Issue is composer.phr file is not in current directory,you need to give full path composer.phr like
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or you can create yii2 project using this command:
composer create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or
composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
I had the same issue. It is solved when I made composer globally available. Now I am able to tun the commands from any where in the folder.
composer update
composer require "samplelibraryyouwant"
Use this :
php -r "readfile('https://getcomposer.org/installer');" | php
Hi friends, follow the steps to fix this issue in MAC OS
Step 1: first run the command in Terminal with your project directory
$ curl -sS https://getcomposer.org/installer | php
Step 2: Move the composer.phar in your project directory
$ mv composer.phar /Applications/MAMP/htdocs/bashrushAPI/composer.phar
Step 3: Setup alias the composer
$ alias composer='/Applications/MAMP/htdocs/bashrushAPI/composer.phar'
Step 4: Check the composer version now
$ composer --version
Composer version 1.7.2 2018-08-16 16:57:12
Step 5: Confirm the project folders and file placed on bellow
$ ls
CONTRIBUTING.md docker-compose.yml templates
README.md logs tests
composer.json phpunit.xml vendor
composer.lock public
composer.phar src
Step 6: Now update composer
$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Step 7: Run your sample project
$ php composer.phar start
php -S localhost:8080 -t public
[Thu Sep 27 03:16:11 2018] ::1:51177 [200]: /
[Thu Sep 27 03:16:11 2018] ::1:51178 [404]: /favicon.ico - No such file or directory
Easy answer, navigate to the directory where you already have the composer.json file that you want to run (ideally your project folder) then download composer into the same folder, then instantly run the install command like so:
php composer.phar install
This will automatically find the composer.json and run your required scripts. Good luck. This stuff is a breeze for terminal wizards and totally bizarre to the rest of us
I am using windows 8.0. In my case to install or update i just use composer install or something else instead of php composer.phar. This worked for me
like
composer require google/apiclient:1.*
To googlers who installed composer via HomeBrew:
make a symbolic link for /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/local/bin/composer.phar
I got this error "Could not open input file: composer.phar" while installing Yii2 using below mentioned command.
php composer.phar create-project yiisoft/yii2-app-basic basic
Solutions which worked for me was, I changed the command to
composer create-project yiisoft/yii2-app-basic basic
I hope it help!
your composer.phar should be placed in above way.
For windows, I made composer.cmd and used the below text:
php c:\programs\php\composer.phar %*
where composer.phar is installed and c:\programs\php\ is added to my path.
Not sure why this isn't done automatically.
For Windows10 Pro, Following steps fix the issue. select properties check the Unblock program option. run the installer, run the command CMD with Admin rights. At command promp run composer --version to make sure it is globally installed. you should be able to now run composer require drush/drush This is for drush dependency using composer.
Command like this :
composer.phar require intervention/image
error: composer.phar: command not found
I solved the problem by following this process
i set the composer globally and renamed composer.phar to composer then run this command composer require intervention/image . and now it's working fine
Just open cmd as Administrator and go into your project folder and check it is working or not using composer command.
The above error is because of the composer is not accessible globally.
So you need to run "cmd" as Administrator.
This is working fine for me.
If you are using Ubuntu/Linux and you are trying to run
php composer.phar require intervention/image on your command line.
Use sudo composer require intervention/image instead. This will give you want you are looking for.
I had an issue getting a package.json's script to run composer dumpautoload.
I had the file /usr/local/bin/composer.phar, and also the file ~/.bash_profile (on OSX) contained:
alias composer="php /usr/local/bin/composer.phar"
This allowed composer to work from the command line, but it didn't allow scripts to execute composer.
The fix was this:
$ cd /usr/local/bin
$ mv composer.phar composer
$ sudo chmod +x composer // +x allows the file to be executable, such as by CLI scripts
But that yielded this error Could not open input file: /usr/local/bin/composer.phar
The fix was to update ~/.bash_profile (sudo nano ~/.bash_profile), and change the composer alias to:
alias composer="php /usr/local/bin/composer"
# ie: `.phar` extension removed
Now everything is behaving as expected.
Your composer.phar must be in Source files. I had same problem and I just cut my composer.phar into mine framework-standard-edition folder, where is my whole strong textproject.
if the composer is already install all you need is to know where the composer.phar file is (its directory) after that you move to your symfony project where you have the composer.json and from that directory you execute your composer.phar file. In windows here is what you have to do.
symfony project directory_where_composer.json_is>php the_directory_where_composer.phar_is/composer update
That's all
use two steps .
curl -sS https://getcomposer.org/installer | php
sudo php composer.phar update
You can do
curl -sS https://getcomposer.org/installer | php
The -sS flag meaning don't show progress, do show errors
and then
php composer.phar install
from:
How do I get cURL to not show the progress bar?
https://packagist.org/
I've reach to this problem when trying to install composer on a Window 7 machine from http://getcomposer.org/download page. As there was an existing compose version (provided by acquia Dev Desktop tool) the installation fails and the only chance was to fix this issue manually. (or to remove Dev Desktop tool composer).
Anyway the error message is quite straightforward (Could not open input file: composer.phar), we should then tell the system where the file is located.
Edit composer.bat file and should look like:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;%PATH%
php.exe composer.phar %*
See that composer.phar doesn´t have a file path. When standing in a different folder than the one where composer.phar is located the system won´t be able to find it. So, just complete the composer.phar file path:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;;%PATH%
SET composerScript=composer.phar
php.exe "%~dp0%composerScript%" %*
Reopen your window console and that should do the trick.
EDIT: this has an issue because it always uses %~dp0%composerScript%
folder as composer execution. Then all configurations are done in that
folder (besides standing on your current project folder) and not in your project folder.
So far I haven't found a was to make a manual composer installation to
work globally on Windows. Perhaps you should go ahead with composer for windows installation mentioned above.
Do not access the composer by
composer composer.pher install
use
composer install
You can just try this command if you're already installed the Composer :
composer update
or if you want add some bundle to your composer try this :
composer require "/../"

Laravel composer absolute path error in VB

I run local virtual box development server with ubuntu 12.04. To access files I use virtual box shared folders which are mounted into ubuntu at /media/Sites. This dir I use as DocumentRoot for apache.
When I try to run composer create-project laravel/laravel --prefer-dist I get error:
[InvalidArgumentException]
$from (/media/Sites/test.dev/laravel/vendor/bin/boris) and $to () must be absolute paths.
I assume problem is because dir /media/Sites is outside of ubuntu in windows 8.1. I also tried to create new laravel project in some linux dir and it worked without any error.
What would be the best fix for this?
Thanks in advance
Be sure you have all of the requirements installed:
$ apt-get install git php5 php5-curl php5-cli php5-mcrypt php5-json
then
$ wget https://github.com/laravel/laravel/archive/master.zip
$ unzip master.zip project
$ cd project
$ composer install --verbose
to see a stack trace of the error, then post it here for more help.
there is some bug in the boris package, were it tries to create a symlink to another directory. the solution to this is to manually create the missing file vendor/bin/boris with this content:
../d11wtq/boris/bin/boris
then run composer update again and it should work. (in our case we had also some additional problem with unaccessible files created by composer - the files exist in host but are not accessible in guest - vagrant reload helps in this case)
Had the same happen to me. Solved it by installing php5-readline.
sudo apt-get install php5-readline

installing PHP module from Elastic Beanstalk

I am trying to configure my AWS Elastic Beanstalk to work with mongo, all I need to do is install the mongo driver for PHP and update the php.ini file
To do this, usually I would ssh into the EC2 and run:
sudo pecl install mongo
But this would require using a custom AMI which isnt the best way to go.
It is better to use config files to install the software required onto the standard AMI.
So to do this, I have done the following:
created directory .ebextensions
created file mongo.config
in it I have put the following:
packages:
pecl: install mongo
However upon deployment, I get the following error:
"option_settings" in one of the configuration files failed validation. More details to follow.
and
'null' values are not allowed in templates
So I am wondering how this config file needs to be laid out in order to install the mongo extension?
I have read the info here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
but I am not quite understanding how to do this specific task
Help would be appreciated , thanks! :)
pecl is not a valid package manager on Amazon Linux and therefore cannot be used under the packages key of an .ebextensions config.
To install a PECL package it is enough to add a single command under the commands key. To avoid that Beanstalk tries to install the extension twice on follow-up deployments add a PHP console command to the test key that checks if the extension is already installed:
commands:
install_mongo_driver:
command: pecl install mongo
test: "php -r \"exit(extension_loaded('mongo') ? 1 : 0);\""
If the test result is true, i.e. exit(0), then the command gets executed - otherwise not. Please note that a exit code of 0 means "No errors" in a shell context.
See also the description at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands.
I have figured it out and thought I would share what I found. Thanks to Hudku (http://blog.hudku.com/2013/02/innocuous-looking-evil-devil.html#elastic-beanstalk.config) for the excellent article:
1) Create myapp.config
2) enter the following into it
packages:
yum:
dos2unix: []
container_commands:
01-command:
command: rm -rf /myapp/ebextensions
02-command:
command: mkdir -p /myapp/ebextensions
03-command:
command: cp -R .ebextensions/* /myapp/ebextensions/
04-command:
command: dos2unix -k /myapp/ebextensions/mongo.sh
05-command:
command: chmod 700 /myapp/ebextensions/mongo.sh
06-command:
command: bash /myapp/ebextensions/mongo.sh
Then create mongo.sh file and put in it something like:
#!/bin/bash
if [ ! -f /mongostatus.txt ];
then
pecl install mongo
echo "mongo extension installed" > /mongostatus.txt
apachectl restart
fi
This will install mongo php extension and restart apache so the install takes affect.
I just accomplished the same thing thanks to the answer above, and figured out it can be done with less lines and less files for those interested...
# ~/project/.ebextensions/project.config
# Logger messages can be viewed in /var/log/messages
files:
"/tmp/test.sh":
content: |
# This file will be created and can then
# be executed by a command call below.
logger TEST FILE CALLED
commands:
01-command:
command: logger CALLING TEST FILE; sh /tmp/test.sh;

Categories