About install Homestead per Laravel Project - php

I'm using Homestead for Laravel Development Environment.
I installed globally Homestead, everything is ok.
However, when want install Homestead per Laravel project, I have a question:
Will I have to install PHP, Composer in Local machine to can run this command ?
composer require laravel/homestead --dev
So I still have to install environment (PHP, Composer, ...) on Local machine when want install Homestead per Laravel project ?

You ssh into your homestead box by cd'ing into your project folder and after successfully running vagrant up you run vagrant ssh and inside your box you can run all your commands.

Related

Enquiries - Laravel website migration steps

I got a website running with laravel framework, this website will need to migrate to public cloud VM. However, I'm not quite familiar with laravel, any suggestion and advice would be appreciated.
I already created a remote VM, and installed Nginx.
Also, I move the root folder from on-prem /var/wwwroot to the cloud /var/wwwroot as well. Moreover, the Mysql database had been imported to the cloud Mysql too (using the dumped .sql file ).
laravel need PHP to run, should I install php5.6 or php5.6-fpm (or both)?
I need to install laravel framework, do I have to install the specific version of lavavel (5.1.46)?
After I install the laravel, do I need to conduct any laravel command such as
~#php artisan migrate ? or just put the wwwroot folder's file should be enough?
Here is more info about the on-prem VM:
~#php --version
PHP 5.6.32-1+ubuntu16.04.1+deb.sury.org+1 (cli)
~#nginx -v
nginx version: nginx/1.13.6
~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
~# php artisan --version
Laravel Framework version 5.1.46 (LTS)
~# mysqld --version
mysqld Ver 5.7.20-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))
Tony.
You want to use NGINX as webserver, so you need to install both packages.
If you install your code from git, you should install dependencies by running command:
php composer install
You should create your .env-file and edit it: set up db connection params and other settings:
cp .env.example .env
Also you should generate app key:
php artisan key:generate
If you copied last version of your db, you don't need to run up migrations, but I recommend you to run new migrations, to be confident that db structure wasn't changed since you make dump.
php artisan migrate

Cannot run artisan command in Laravel Homestead

After setting up Homestead for 1 specific project only, I want to run the Artisan CLI for database migrations. I tried to follow this tutorial and I keep getting this error:
Could not open input file: artisan
I set up the project by running these commands (Windows):
composer require laravel/homestead --dev
vendor\\bin\\homestead make
vagrant up
And then I made sure to be in the root project directory and then run php artisan list, which gives the error above.
I also tried to ssh into the Homestead VM and navigated to the code folder (where my project resides) and run php artisan list, to which it gives the same error.
Attached is my working directory where I run the artisan command, as requested:
I have tried running it in root dir and in vendor\\laravel to no avail.
So how would one run the artisan CLI in a Laravel Homestead project?
I think I've figured it out. The problem was that I haven't set up a Laravel project using composer yet, and skipped to install Laravel Homestead for this project.
So to make a Laravel project named e.g. quickstart, one should first create the project by running
composer create-project laravel/laravel quickstart --prefer-dist
(see https://laravel.com/docs/5.1/quickstart#installation for more details)
Only after that, set up homestead for the project by running
composer require laravel/homestead --dev
vendor\bin\homestead make
And now the project should be fully initialized.
Refs: https://laravel.com/docs/5.7/homestead#per-project-installation

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: How to install php7 with Homestead

I m a newbie and learning Laravel. I m having a trouble with install php and homestead.
As I read in Laravel Official Website:
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.
So I think I do not need to install php in my local machine ??? But when I install composer, it requires PHP.exe and I cannot browse that PATH. I misunderstand here. I have been stuck in this problem and research many websites for whole day, so I think better to ask (even if it is stupid question). Could anyone explain for me please...
---EDIT_NEW---
This is my completed steps to use Laravel:
Install git
Install virturalbox
Install vagrant
vagrant box add laravel/homestead
git clone https://github.com/laravel/homestead.git Homestead
cd Homestead, bash init.sh
Configure Homestead
add to Hosts file
Now I have to install laravel, it requires composer. Composer installation requires php.exe PATH. But if I dont use XAMPP or others local development environment, how can I install Composer ?
(Note: Maybe I misunderstand here "without requiring you to install PHP, a web server, and any other server software on your local machine").
Are you executing composer "inside" Homested vagrant VM or in windows "cmd"? In the first case it's strange in the second of course it doesn't work. You need to acces the Homestead VM via SSH
Thanks for help, with your answers and Laracast Video: https://laracasts.com/lessons/say-hello-to-laravel-homestead-two. Now I got the answer.
You need to follow some steps to running Laravel in your system (windows 10).
1) Install XAMPP or WAMPP, you can download XAMPP from Here.
2) Install composer, find it from Here.
3) Install GIT (optional).
Than go for create New Laravel App.
1) Open Terminal -> goto C:/xampp/htdocs/
2) composer create-project laravel/laravel <App_Name>
3) php artisan serve

Categories