laravel is not recognized as an internal or external command - laravel

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"

Related

"laravel: command not found" after installing Laravel

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.

Laravel installation tutorial says to add ~/.composer/vendor/bin to my $PATH, but it doesn't exist

I've tried a couple of methods to install laravel, including this command:
composer global require "laravel/installer=~1.1"
As far as I can tell, it installs. Certainly it creates a number of directories and files, including an app directory...
When I run laravel, I get command not found. Googling, I find that I should add ~/.composer/vendor/bin to my $PATH. The problem is that I don't have that directory. I do have ~/.composer/cache, but the cache directory is the only one I have in ~/.composer.
Any ideas on what to do? Am I missing a step? I've read a half dozen tutorials now on installing laravel. :-/
Sometimes Laravel is in the path ~/.config/composer/vendor/bin path. Try adding that path. But first make sure to go to that path and verify there is laravel.

PHPUnit - How to add vendor/bin into path?

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.

How to install Laravel 4 profiler

I'm a Ubuntu/git/composer noob, and I'm trying to follow the installation instructions here.
After running the php artisan config:publish loic-sharma/profiler command I get the following error:
PHP Fatal error: Class 'Profiler\ProfilerServiceProvider' not found in /var/www/epcr/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 158
I'm assuming the problem is that I haven't downloaded the code, but I'm not exactly sure how to go about doing that.
Most packages require you to manually add service provider in app/config/app.php. There is an array of providers inside.
Some providers require also facade alias.
So take a look at documentation, if it is provider, then it should be documented.
e.g.
'Miro\JSONSuite\JSONSuiteServiceProvider'
Try running composer dump-autoload
I needed to run composer update after I added the require to my composer.json file. After that I had a few permissions I needed to update and it worked after that.

Laravel installation

No existing questions are sufficiently basic to answer my problem. I am trying to install Laravel to try it out and have successfully installed Composer but all advice about installing Laravel itself seems to involve something called Git and a 'terminal' which I know nothing about. Can I not simply download a setup file and run it as for other apps?
Mike
Install Laravel Framework in Windows:
Created By : Chirag Shah
PHP version greater than 5.3.7 is required
Step 1: Download Laravel from: https://github.com/laravel/laravel/archive/master.zip
Step 2: Extract Laravel into the www folder for WAMP (http://www.wampserver.com)
Step 3: Download Composer from: https://getcomposer.org/Composer-Setup.exe
Step 4: Install Composer into the same directory php.exe is located
Step 5: Click on WAMP icon->PHP->PHP Extensions and enable: php_openssl, php_curl, php_socket
Step 6: Click on wamp icon->Apache->Apache Modules and enable ssl_module
Step 7: Enable openssl from all php.ini files
Step 8: Open cmd
Step 9: Change into the directory where you extracted Laravel e.g: cd C:\wamp\www\laravel
Step 10: Type the command: composer install
step 11: Copy and paste all \public\ folder files into WAMP's www folder
Step 12: Open bootstrap\paths.php and edit the line 'public' => DIR.'/../public', to 'public' => DIR.'/../www',
Installation completed.
Enjoy....
Yes you can, this is the link to the zip file:
https://github.com/laravel/laravel/archive/master.zip
But at some point you might need Git, so you better get along with it. :)
Hi sorry to let you know that laravel at some point requires you to handle a terminal. Git is not a necessary attribute for just a try out. Terminal is nothing to be scared of - its actually the command line which is referred to as the terminal.
You can get a lot of tutorials and help on how to use terminal effectively. And using the terminal solves you a lot of trouble too. If you are interested in learning and programming in laravel take an interest in studying the terminal too.
Steps to install 5.1 laravel in windows using wamp or xampp:
-> Step 1: install laravel composer (you can download it from https://getcomposer.org/)
-> Step 2: open command prompt then download and install laravel installer using composer by the following command:
composer global require "laravel/installer=~1.1"
-> Step 3: Right click on my computer then go advanced tab then environment variables and in system variable search for path -> and put the following code in the end of line after ;(semicolon) :
;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin;
-> Step 4: then go to wamp directory ie: e:wamp/www/ (i have installed wamp in E directory)
-> Step 5: open command prompt and select the current directory using following commands:
1. e:
2. cd www/laravel
-> Step 6: in command prompt run follow command:
laravel new blog
Now laravel project with name blog is installed on your local machine using wamp or xampp.
open http://localhost/laravel/blog/public in your browser.
on success you will see laravel 5 logo.
Enjoy with laravel installation.

Resources