Homestead Laravel Paradox? - php

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

Related

The provided cwd "/home/www/myproject" does not exist

I used to map only one folder to my projects root folder as recommended in Laravel 5.6.
Now, I mapped each folder to each separate project as recommended in Laravel 6.x.
Now if I login into my VS with vagrant ssh and try laravel new myproject I get
The provided cwd "/home/www/myproject" does not exist
If I create the folder beforehand, than I get
Application already exists
If I install as root, then Laravel gets installed, but I can't find my project on my PC. I see it on my VS, buts it not on my hard-drive.
This is the config in my Homestead.yaml:
- map: ~/www/homestead/myproject # Path on my laptop
to: /home/www/myproject #Path of VM
I find /home/www/myproject which I created on my VS, but ~/www/homestead/myproject does not exist on my PC.
I did not have these issues when I was only mapping one folder. How can I fix this and create a new Laravel project?
I solved this by installing Laravel command globally with composer on my PC. To do so, I had to install zip first:
sudo apt-get install php7.2-zip
Then I could install it globally
composer global require laravel/installer
Which displayed
Changed current directory to /home/adam/.config/composer
and I had to add this to my ~/.profile:
PATH="$HOME/.config/composer/vendor/bin:$PATH"
I reloaded profile in command with source ~/.profile and then I finally could install Laravel from my PC instead from the VM.

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

About install Homestead per Laravel Project

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.

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

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