Error trying to run composer with Laravel 4 - laravel-4

I am new to Laravel and to using the terminal.
I installed composer globally and it is running, but when I try to mv I get an error:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
No such file or directory
I echo $PATH and get this:
/Users/ebernal/.rvm/gems/ruby-1.9.3-p286/bin:/Users/ebernal/.rvm/gems/ruby-1.9.3-
p286#global/bin:/Users/ebernal/.rvm/rubies/ruby-1.9.3-
p286/bin:/Users/ebernal/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Not sure what all this means, and why can't Terminal not find /usr/local/bin?
I can run composer using composer.phar and it mostly runs, but at the very end I get this error:
Script php artisan clear-compiled handling the post-install-cmd event returned with an
error
[RuntimeException]
Error Output:
Thanks for your help

As it says in the error message, no such file or directory.
Locate the /usr/local/bin/composer file. Show hidden folders or use the cd command to navigate through Terminal.
You possibly don't have a composer folder, hence why it can't move it into it.

Related

Composer installed, get env: php: No such file or directory

I am using MAMP on macOS 12 (Monterey), so I want to run through MAMP to use PHP. Therefor I added this alias:
nano ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.4.10/bin/php'
Then I ran:
curl -sS https://getcomposer.org/installer | phpmamp
Which resulted in:
Composer (version 2.4.2) successfully installed to: /Users/johnmiles/composer.phar
Use it: php composer.phar
Then I made it available globally:
sudo mv composer.phar /usr/local/bin/composer
But when I run composer I get:
env: php: No such file or directory
So how do I tell composer to use phpmamp?
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/Applications/MAMP/bin/php/php8.0.8/bin:$PATH
Hit ESC, Type :wq, and hit Enter
In Terminal, run source ~/.bash_profile
In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).

Laravel ErrorException No such file or directory

I have uploaded my Laravel project on ubuntu server via putty terminal.
Composer installed on server machine but when i run any artisan command it gives an error.
$ php artisan serve
ErrorException
require(/var/www/html/healthapi.fynity.in/routes/api/v1/api.php): failed to open stream: No such file or directory
The api.php is already there but i don't know why this error comes. Tried all the solutions from google.
Problem:
You may have changed something earlier such as the name or the path of the file.
Solution:
First of all, you use the following command to clear all configs.
$ php artisan config:clear
Then, you run again the following command.
$ php artisan serve
Update (2021/01/07):
You got the following error:
ErrorException require(/var/www/html/healthapi.fynity.in/routes/api/v1/api.php): failed to open stream: No such file or directory at vendor/laravel/framework/src/Illuminate/Routing/RouteFileRegistrar.php:35 31
It seems that the library is not fully installed. You should update the library with the following command:
$ composer update
Then, you run again the following command:
$ php artisan serve

Composer: Command Not Found on Mac

I have installed Composer as per the instructions command not found
After installing I get the prompt that Composer is successfully installed but when I go to check the version it gives me error "Composer: Command Not Found"
I have been looking how to fix this issue and I had to read and understand little bit and the environment variables on MAC.
I understand the issue looks simple but it will get over complicated if you didn't understand how to install composer probably.
Solution 1
I found this solution here: https://duvien.com/blog/installing-composer-mac-osx
Open a terminal and navigate to your user directory, ie cd /User//
Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called composer.phar:
curl -sS https://getcomposer.org/installer | php
Now we move composer.phar file to a directory
sudo mv composer.phar /usr/local/bin/
We want to run Composer with having to be root al the time, so we need to change the permissions:
sudo chmod 755 /usr/local/bin/composer.phar
Next, we need to let Bash know where to execute Composer:
nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:
source ~/.bash_profile
Finally, run:
composer --version
Solution 2:
I understand that the first command you will find online when you try to google this issue would be
curl -sS https://getcomposer.org/installer | php
But actually this is the main terminal installation but sometimes I wanted to manually install the composer, so this 2nd solution about manually installing the composer in specific directory
First of all you need to understand where are you now on the terminal
use
pwd
and then install composer manually using the following commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') ==='baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
to use it on that case you will read on the terminal to use this composer installation use
Use it: php composer.phar
so just write
php composer.phar
and it should be working.... one more thing, during this installation you can install the composer to specific directory / project folder... in that case you can use a flag with command No.4 to tell the terminal to install the composer in specific directory...this flag is --install-dir=your-directory-path
and you will the terminal this time after installing composer asking you to use the following path to call the composer
Use it: php /Users/muatafa/composer.phar
if you want to read more about this issue, I think you must read the composer documentation how to install it>>> https://getcomposer.org/download/
that's how I solved my current issue... if you still have any issues comment on this replay & Hopefully we can figure it out!
I had the same problem. "composer require something" works if installed in global and not locally.
If you install composer locally you'll then install dependencies using "php composer.phar require nameofyoudependency"
To install globally open a terminal to install as mentionned on the composer website. Then run "sudo mv composer.phar /usr/local/bin/composer"
Now you can use "composer" directly to install dependencies like => "composer require something/sdk"
the composer you installed is still named /usr/local/bin/composer.phar - look in the second yellow/brownish line in your output. Just rename it to just composer
Your composer command is not set to path, use
export PATH=$PATH:/usr/local/bin/
I had the same issue, After installing composer using the command line on their website. I forgot to put composer.phar into a directory on my PATH, so it can simply be called from any directory (Global install). and then I ran this command "sudo mv composer.phar /usr/local/bin/composer" and it was resolved
I figured out. in place of "composer require twilio/sdk" I needed to use
"composer.phar require twilio/sdk" since I am on mac. It worked

Laravel Artisan not working at all after clone

I have this weird situation: I've cloned all my repositories from github in a new local machine running Mac OsX some of them has Laravel framework installed but only some of these can execute the cmd php artisan.
I've tried to check permission on folders, uninstall/re-install composer and I've also tried to install a fresh version of Laravel. Another problem is that running the command doesn't output anything - no errors, nothing - only a new empty line of the terminal.
The only thing I know is that if I clone one of the repositories, then run composer install it throws Script php artisan optimize handling the post-install-cmd event returned with error code 255.
Thanks
Update 1:
I've found running composer install -vvv -o that composer throw this error
Warning: require(/Users/USERNAME/laravel/bootstrap/autoload.php): failed to open stream: No such file or directory in /Users/USERNAME/laravel/artisan on line 16
Fatal error: require(): Failed opening required '/Users/USERNAME/laravel/bootstrap/autoload.php' (include_path='.:') in /Users/USERNAME/laravel/artisan on line 16
Update 2:
It seems that cmd git clone didn't copy that autoload file bootstrap/autoload.php for some reason that I don't understand at all.
I've imported the file manually from github and run, removed the vendor folder then run again composer install --no-scripts but still having the problem with artisan and if I run composer update it throw Script php artisan optimize handling the post-update-cmd event returned with error code 255
I had to re-install laravel and copy files manually to make it works again.

Laravel package installation on live server

How to install package in laravel on live server, whenever I run "command composer require monolog/monolog". It gives error Could not open input file: /home/root/composer.phar
First of all, you should not run composer require on live server. You should only run composer install so you should require it locally, test if everything is working fine and then on live server just install library that is tested in your application.
About error:
Could not open input file: /home/root/composer.phar
make sure this file really exists (if not you can download it from Composer site) and make sure it has correct permissions (it should have execute permission) - use chmod +x composer.phar to make it executable
Please try like this.
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
$ php composer.phar update monolog/monolog
You can install package without any problem.

Resources