Why I can't use "laravel" command inside Homestead VM - php

I am new to laravel.
So, I have successfully installed and configured Homestead on my Windows machine.
Then I wanted to install Laravel. As I said, I am on Windows, so obviously I don't want to install php, composer and all that stuff on it, that's why I just hit "vagrant ssh" to get inside Homestead and then tried to install laravel following the official documention
composer global require "laravel/installer"
Then I tried to run "laravel" command, but no luck - command not found. I decided, that I had to edit PATH variable, but then I found out that there is no "~/.composer/vendor/bin" folder at all (not it inside /home/vagrant or /root).
and after I got stuck. What do I do wrong, guys?
P.S. "composer create-project --prefer-dist laravel/laravel blog" works fine, but I want to find out how to make "laravel" command work

I don't believe there is a laravel command-line executable.
Are you trying to run artisan commands?
docs

when you run composer global require "laravel/installer" what did it say ? it should output
Changed current directory to /home/vagrant/.config/composer where laravel will be installed
so you can just add /home/vagrant/config/composer/vendor/bin (note config vs what you say ~/.composer/vendor/bin) in your PATH variable and laravel command will work

Related

Error when trying to install laravel/create a laravel project on windows via composer

I want to create a new project using Laravel.
From the documentation, I downloaded Composer using its Windows executable installer.
I have already set the path to: C:\Users\marti\AppData\Roaming\Composer\vendor\bin
**I created the vendor\bin directory
From the command prompt, the command "composer" works.
I tried to install Laravel using the laravel installer and it gives me an error also with the create-project command.
I have tried both methods even with administrative privillages but still there is an error.
Using Laravel Installer:
[ErrorException]
file_put_contents(C:\Users\marti\AppData\Roaming\Composer\vendor\bin): failed to open stream: Permission denied
Using create-project method:
[InvalidArgumentException]
Composer could not find the config file: C:\Users\marti\AppData\Roaming\Composer\vendor\bin
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting S
tarted" section
PLEASE HELP!
Error when using laravel installer
Error when using create-project method
I deleted the Composer path variable, changed directory to read "C:>" and ran the command "composer global require laravel/installer"
Try requiring Laravel installer from composer composer global require laravel/installer then simply make a new laravel project laravel new {PROJECT_NAME}
Composer(for windows), as of build v1.10.13 does not require you to manually set then env path variable.
You dont have to change or add anything in the composer installation directory or to environment path variable.
If you have done so, then do the following
Re-install composer.
Run composer in a new cmd window, to see if its is installed properly.
Run composer create-project --prefer-dist laravel/laravel <your project name> and now your project should be set up properly.

bash: laravel: command not found

I am Using my own Machine Kali Linux 2.0 Debian x64 . Now, i have Installed Laravel in my directory structure like
/opt/lampp/htdocs/learning-larvel/
Inside the Learning-laravel folder i have Installed my Laravel files, and also i installed composer. So when i go to http://127.0.0.1/learning-laravel/public . I see a See a White Screen and in Between it is written "Laravel 5", which means the Laravel GUI Setup is fine.
Now, to create a new file for Laravel, when i open my Terminal and type
laravel new xyz
then it gives me a error which says bash: laravel: command not found
Now, how can i fix the error.. I have researched about it by setting PATH to bashrc. But i am not getting it fixed right. Additionally when i type in my command composer -version then also it says bash: composer: command not found but i have Installed composer on the folder learning-laravel itself.
I could also see files like composer.phar there in /opt/lampp/htdocs/learning-larvel/
Any help would be extremely thankful.
As the composer official getting started page points out:
There are in short, two ways to install Composer. Locally as part of
your project, or globally as a system wide executable.
if you wanna do composer -- or laravel -- in command line, you wanna install them globally.
Check out the following links:
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
https://laravel.com/docs/4.2#install-laravel
I encountered the same problem. Apparently, the composer exists in path ~/.config/composer/vendor/bin when running as super user. Therefore, replacing the paths which were described above by this, and it should work. Hope it helps.

error using composer to install cakePHP 3

i am lost...
i am trying to do it the right way and am following the Quick Start Guide for installing cakePHP 3 on my ubuntu machine.
Got composer installed. Directory is /var/www/cakephp
and am trying to issue:
php composer.phar create-project --prefer-dist cakephp/app mayapp
or
composer create-project --prefer-dist cakephp/app may app
then i am simply getting:
[InvalidArgumentException]
Could not find package cakephp/app with stability stable.
i do not have a clue what i am doing wrong. Any suggestions?
cakephp/app exists on https://packagist.org, and the command looks ok to me.
Which PHP version are you using? That package is only available with PHP 5.4.16 or later, so you must update if you want to use CakePHP.
However, it is a good idea to only use the same PHP version of your public hosting, using a newer version will lead to problems when deploying your code. If your webspace or public server does not have the latest PHP 5.6 running, ask for an update.
I got same issue. But, as previous answer, myapp does not exists on packagist.org, so, you must use laravel/laravel instead, and, after created, rename the new laravel folder to your desired name and move to htdocs (for xampp) or www (for wamp), then, and I do not know why, go to : localhost/laravel/public/
and replace laravel with the name you gave to your project folder instead the laravel one.
You will see Laravel 5 fonts will appear on screen.
That's means Laravel is running.
Hey Please try these steps.
Download XAMPP Server.
Install XAMPP server.
Go to ..\xampp\php\php.ini and open.
Add this line (extension=php_intl.dll) or if exist uncomment.
Download Composer setup from https://github.com/composer/windows-setup/releases/
Install composer and give php.exe file in path
Open cmd and check now php version using command php -v. if its showing php version its means its working.
Now open cmd and cd on xampp\htdocs folder & run command composer create-project --prefer-dist cakephp/app app_name
Finished folder created in htdocs.
Hope this is helpful for you.

Laravel installation withouth vagrant

Is it possible to install Laravel Framework withouth installing vagrant first?
I just read about vagrant and seems just great, however I think I will skip it for now.
I "installed" Laravel through composer, but when I tried to use the Laravel command:
new <app-name>
The console outputs:
laravel command not found.
I already set the ~/.composer/vendor/bin route to the $PATH
In your ~/.profile file you should have something like this if you are using a mac
export PATH="~/.composer/vendor/bin:${PATH}"
If you are using Ubuntu you should have something like this in your ~/.profile file
PATH="~/.composer/vendor/bin:$PATH"
Finally, if you haven't installed the CLI tool for the Laravel Installer just run this code in the terminal
composer global require "laravel/installer=~1.1"
You need to install laravel in order to use it.
Use composer global require "laravel/installer=~1.1" to install laravel

Installing Laravel

I am on a windows 8 machine and I'm trying to learn laravel. I copy and pasted my PHP folder from C:\xampp to C:\php, installed composer, ran composer install then composer create-project laravel/laravel learning-laravel. So far everything was created so I went into the directory and tried to use 'php artisan serve' and got the following error.
C:\Users\denni_000\learning-laravel>php artisan serve
Warning: require(C:\Users\denni_000\learning-laravel\bootstrap/../vendor/autoloa
d.php): failed to open stream: No such file or directory in C:\Users\denni_000\l
earning-laravel\bootstrap\autoload.php on line 17
Why you copied php folder
download composer install it.
download laravel latest version and store it on your xampp/htdocs/laravel
and run cmd with composer install command
For more follow install laravel on windows xampp
or Laravel 4.1 installation with composer in xampp
For windows Simply download Laragon which includes latest php 5.6.7, Apache, Mysql, Redis, Memcached an alternative to Xampp or Mamp with small size. Easy to install laravel and create project with auto create virtual host by it. Thank you.
U need to go to the directory where laravel is installed and run the following command.
composer update
Install Laravel 4.2 with composer:
sudo composer.phar create-project laravel/laravel project-directory-name 4.2 --prefer-dist
Here is a different way to setup laravel, may be you guys will like it
Step 1:
Clone https://github.com/laravel/laravel or you may download zip also.
Step 2:
Navigate to downloaded folder in command prompt and run composer install
Step 3:
open the folder and rename .env.example to .env and update the credentials mentioned in file.
Step 4:
After these steps if you navigate to the directory from web-server it will cause an error No supported encrypter found. The cipher and / or key length are invalid. to fix this just run php artisan key:generate
Done!
Hope you guys like this way :)
You need to install all the laravel required dependency.
To do that, you need to tell composer to install everything needed.
Below is the command to use to install that's required in laravel composer.json.
composer install
Follow the installation guide from Laravel
Install Composer:
Like Laravel.com says: "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable can be located by your system."
Type the following statement in the command line:
composer global require "laravel/installer=~1.1"
Create a fresh Laravel project in a specified directory with the "laravel new" command:
laravel new blog
You can also create a Laravel project using composer, like such:
composer create-project laravel/laravel --prefer-dist
If you want to learn laravel I seriously recommend you use laravel homestead with vagrant.
For this you need to:
Install virtualbox.
Install vagrant.
Install git.
Install ssh.exe (Download msysgit and copy the content of bin folder to git bin folder).
Install Homestead on Vagrant (Follow the steps on laravel/homestead documentation page).
Install Laravel on Homestead (Follow the steps on laravel/installation documentation page).
This method apply to Windows, Linux or Mac, only change the step 4 on linux or mac.

Categories