homestead init not defined - php

While installing homestead following the official installation instructions of version 4.2, I received the following error message when executing $ homestead init:
i.e.
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "init" is not defined.
My step before that was to install homestead with composer global require "laravel/homestead=~3.0"
I installed Laravel Homestead version 3.0.1 and homestead is in my PATH.

Hmmm I remember having this problem when I was first installing homestead. I can see the link you provided is in relation to Laravel 4.2. Following the homestead installation from the 5.2 docs seemed to be fine for myself however:
Laravel Homestead: Installation & Setup

The solution is very simple.
Make sure you have added this to your bash profiel or .zshrc file.
function homestead() {
( cd ~/Homestead && vagrant $* )
}

Related

Homestead Laravel Paradox?

I try to create a clean project with Laravel and Homestead, so that if somebody download my project, only a vagrant up is necessary... look like a Paradox or maybe I do something wrong.
I create a new laravel project dir
I run composer require laravel/homestead --dev to install homestead.
I get requirements errors because the composer.json was already created from laravel, and it needs the requirements from the VM
I could do a composer install inside the homestead VM
But the homestead VM doen't exist already because I can't install homestead
To make homestead works but not the right workflow:
I did a composer require laravel/homestead --dev outside the laravel dir and I copied the homestead files inside the laravel project dir
vagrant up from the laravel dir
composer install in the VM (this remove all the homestead files because homestead isn't in the composer.json)
This looks wrong, which would be the right way to add homestead to a laravel project?
Ok I figure it out.
You can put the homestead folder and the laravel folder in the same project, like:
--project_folder
|--homestead
|--laravel
And change the path in Homestead.yml to the laravel dir
Then to take the project running:
do a compose install in homestead
vagrant up
in the VM compose install to prepare the laravel app

Using Laravel Homestead for PHP5.6 and PHP7 projects

Here at the office we are using Homestead as our local development environment. All projects we had so far were made in PHP5.6. Now we have a new project and we are going to use PHP7. I can't run PHP7 in my current PHP5.6 homestead machine. How can I achieve to run PHP5.6 and PHP7 projects? They do not have to run at the same time, so I if it's possible to change the Homestead.yaml to use a newer version, that would be fine.
What I have tried already was to run vagrant box add laravel/homestead --box-version 1.0.1. This added the 1.0.1 box but when I added version: 1.0.1 to my Homestead.yaml and started vagrant the PHP version was still on 5.6.
In case people find this post - the answer has changed.
If you run Homestead v6 or above - you automatically get multiple PHP versions installed by default.
In your Homestead.yaml file you can set the version:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
php: "5.6"
In addition, you may use any of the supported PHP versions via the CLI:
php5.6 artisan list
php7.0 artisan list
php7.1 artisan list
Check the Laravel docs for more info: https://laravel.com/docs/5.4/homestead#multiple-php-versions
The latest Laravel-Version with Homestead including PHP 5.6 is Laravel 5.6. See https://laravel.com/docs/5.6/homestead for details and installation instructions.
Use the following commands during installation to get this Homestead-Vagrant-Box:
vagrant box add laravel/homestead --box-version 6.4.0
git clone https://github.com/laravel/homestead.git .
git checkout v7.20.0
This Homestead-Version supports PHP 5.6 to 7.3.
(More details in german: https://blog.dmr-solutions.com/blog/homestead-vagrant-box-mit-php-56)
Found a solution! I followed this tutorial. I can run a PHP 5.6 and a PHP 7 Homestead. The only thing I had to do (I already have a PHP 5.6 homestead configured) was:
Clone the latest homestead version in a Homestead-7 folder (or a different name) by running git clone https://github.com/laravel/homestead.git ~/Homestead-7
Go into this directory and run bash init.sh and answer no to all questions.
That's it! You might have to upgrade your vagrant (mine was too old) but that's easy to do by just downloading the latest version on https://www.vagrantup.com/downloads.html (Do not forget to run vagrant provision in Homestead-7)
I like to add to Laurence answer.
After adding php5.6 to Homestead.yml, you cannot simply do "vagrant up --provision". It will not work. You have to actually destroy the vm by running command "vagrant destroy" and recreate back the vm.
So before destroying the vm, better to backup every database you have in there. I do this by dumping all the sql in Code folder. Later after I run the command "vagrant up" I can simply ssh to my vm and go to mysql and run "source dump.sql" in mysql command line again.

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

Laravel Homestead: 'homestead init' -> could not open input file

I am trying to install the latest version of Laravel Homestead on my PC and when I try running the command homestead init in my command terminal, I keep getting a "Could not open input file" error.
Steps I've taken so far with installing Laravel Homestead:
1) Created a new directory at C:\Users\Jeff\Desktop\Code
2) Installed Composer
3) Installed VirtualBox and Vagrant Box
4) In 'cmd', ran the command vagrant box add laravel/homestead
5) Copied the Composer files from C:\ProgramData\ComposerSetup\bin into my C:\Users\Jeff\Desktop\Code directory.
6) In 'cmd', ran the command composer global require "laravel/homestead=~2.0"
Since I am following the Laravel homestead installation guide the next step is to copy the ~/.composer/vendor/bin directory to my PATH so that the homestead command is executable but this is where I get confused.
I have tried a couple of things but they have not worked for me.
In my ~/.composer/vendor/bin directory, I have copied the homestead directory files into my C:\Users\Jeff\Desktop\Code directory but when I try running the command homestead init, I keep getting the error Could not open input file: C:\Users\Jeff\Desktop\Code/../laravel/homestead/homestead
On Windows use homestead.bat init instead of homestead init.

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