After I am using
composer global require laravel/installer
it seems the installation is success. For the second time, the result is:
Changed current directory to /home/ryanadhi/.config/composer
Using version ^3.1 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
13 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
then if I do
echo $PATH
the result is
~/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/ryanadhi/go/bin:/home/ryanadhi/.composer/vendor/bin
However if I try
laravel
the result is always:
laravel: command not found
Editing the ~/.bashrc in Ubuntu 20.04 to reflect the path shown in the "Changed current directory to /home/ryanadhi/.config/composer" , message. fixed this for me.
first
gedit ~/.bashrc
then edit the line
export PATH="/home/ryanadhi/.config/composer/vendor/bin:$PATH"
You need to add /home/ryanadhi/.config/composer/vendor/bin to your path.
The output that said "Changed current directory to /home/ryanadhi/.config/composer" means that /home/ryanadhi/.config/composer is your Composer global directory.
If your still having issues running the laravel command you can symlnk laravel to /usr/local/bin/
Use this command:
ln -s ~/.composer/vendor/laravel/installer/bin/laravel laravel
Worked for me
I had to do two things, first I needed the "~" in front of the path in the bashrc file. My path line was:
export PATH="~/home/stephen/.config/composer/vendor/bin:$PATH"
and I had been putting "sudo" in front of "laravel new..." command which didn't work.
With those changes it installed as expected.
Related
I have tried to install html2text via composer to my laravel application. Here is a link to the html2text repository. https://github.com/mtibben/html2text
I have tried composer require mtibben/html2text giving this error:
[InvalidArgumentException]
Could not find package mtibben/html2text at any version for your
minimum-stability (stable). Check the package spel ling or your
minimum-stability
Also I have tried composer require https://github.com/mtibben/html2text.git giving this error:
[UnexpectedValueException]
Could not parse version constraint //github.com/mtibben/html2text.git:
Invalid version string "//github.com/mtibben /html2text.git"
How do I install html2text?
Its a php package, u can't install with composer require
U may want to read this tutorial
http://laraveldaily.com/how-to-use-external-classes-and-php-files-in-laravel-controller/
Do you already have a composer.json file in your directory? If not, this could be the error, because in this file you will configure which version of the package you want to install in to your project.
The second exception gives a hint to that missing version!
If you have a composer.json file please add its content to your question, so that we can take a look at it.
Here you can find further informations:
https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup
i faced the same problem.
And neither the creation of releases, nor any tags helped.
The solution for me turned out to be updating the composer from last version.
it's for composer, nothing else. If you already installed composer and composer version is 2 then convert it to version 1.easy way to solve this problem is ,delete the composer folder from your system and re install it. download from here: https://getcomposer.org/
While intstalling laraveldaily/quickadmin I got the following error.
Please help me to solve my problem.
As you can read in the error message
intervetion/image requires ext-fileinfo
You need to enable ext-fileinfo by editing your php.ini and change the following line by removing the ; at the beginning.
From:
;extension=php_fileinfo.dll
To:
extension=php_fileinfo.dll
Find out which php.ini to edit
Run php --ini from a terminal. Make sure you run this command from terminal as the CLI version of PHP may have loaded another php.ini than the web version. Your phpinfo() may not contain the correct path.
As error describes, laraveldaily/quickadmin requires intervention/image which again requires ext-fileinfo. This library is maintained by php_fileinfo.dll
php_fileinfo.dll is a dll(library file) which contains modules to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file.
To fix this error first go to the directory of your php installation.Go to the ext folder and make sure that php_fileinfo.dll is present.
Now open your php.ini file (To locate that, type php --ini on the command line, also suggested by #peh) .
In the php --ini file just add the following line.
extension=php_fileinfo.dll
and recheck with the composer.
I use composer to manage packages. But I delete one of files from package (I use composer status -v to check this).
Is it possible to restore changed/deleted files to it base (installed) state via composer (composer install doing nothing in my case) ?
Thanks.
ps. It's look like there no way to restore separate file from repo, after his been changed/deleted. Of course, it's possible to delete entire vendor dir, and reinstall some package totally.
I edit dependant package source code all the time and run into the issue of my local being out of sync with the remove source.
When things get really sideways and nothing works: delete the package providers dir inside the ./vendor (exp: ./vendor/author-name). Then composer will see the package is missing when running composer install. It will re-download the version specified in composer.lock.
If you want the latest version of all the packages when re-installing; composer update is what you want.
I also recommend using -o -vvv to generate the AuoLoader file and provide verbose output.
I installed PHPUnit with composer. Everytime I run it, I have to call vendor/bin/phpunit. How can I put vendor/bin into path, so that next time I only need to call phpunit to run it?
You could add the current directory into your path.
For Linux/Mac add the following into your .bash_profile, Windows would be similar, alter the line below and add it into your PATH.
# include the current `vendor/bin` folder (Notice the `.` - This means current directory)
PATH="./vendor/bin:$PATH"
Remember to restart your terminal or resource your bash_profile.
Now you should be able to run: phpunit and it will automatically look for it within ./vendor/bin and if it exists it will execute using that.
If you are running on Homestead (or some other Linux/Ubuntu system):
alias p='vendor/bin/phpunit'
Then you can just type p and it will run your tests
If you are using Homestead - you can add this alias to your aliases file so it is always there.
Another easy solution, from the composer documentation, is to set your bin-dir setting to ./. This will install the binary in your root directory.
"config": {
"bin-dir": "./"
}
Then you can just run ./phpunit. I typically set bin-dir to bin, then type bin/phpunit. It's short enough for me.
If you already have phpunit installed, you will need to delete the vendor/phpunit directory and rerun composer install before composer will move the binary.
I'm trying to start laravel,
Found the following line in their tutorial:
Make sure to place the ~/.composer/vendor/bin directory in your PATH
so the laravel executable is found when you run the laravel command in
your terminal.
I don't understand what I should do ?
I added ~/.composer/vendor/bin to my system variables, and then tried using 'laravel new blog' in the command line but got the following message :
laravel is not recognized as an internal or external command
what should I do?
Use correct path to the Composer bin directory.
Good:
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
Bad:
~/.composer/vendor/bin
For Windows add
C:\Users\MyUserName\AppData\Roaming\Composer\vendor\bin
... to directory by going to "My Computer" > "Properties" > "Advanced" > "Environment > Variables" > "Path".
Note: MyUserName is your pc username .
Restart your PC and it would work
For me after adding PATH to environment variables result was the same. I found me answer here
So at first you have to run in cmd
composer global require "laravel/installer=~1.1"
and then the message appears
" Changing directory to
C:\Users\USER\AppData\Roaming\Composer\vendor\bin "
and after that you can run your command. For example
laravel new blog
You need to install Laravel using
composer global require laravel/installer
Otherwise, even adding it to PATH won't help.
First, use:
composer global require "laravel/installer=~1.1"
Then, you can try again.
laravel new project
This problem is happening few many reasons like wrong installation path and conflicts with previous project creation. To solve this problem
first: composer global require laravel/installer
then: laravel new admin ProjectName
this command has solved my problem.
composer global require "laravel/installer=~1.1"