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
Related
I'm using Buddy Works to deploy my project to a server.
When creating a pipeline to deploy my Laravel project, I'm asked to enter deployment actions; this is where I'm stuck.
So far, I have set it to run the following composer commands:
composer validate
composer install
Because this is usually what I do when running my project locally. But I understand that I also need to run Apache and such (I use WAMP so it sorts all that for me).
I've searched on Google and all I got was composer install. Is this all I need to do or is there more?
Prior to using deployment tools, I used to upload files directly to the server, so CI/CD or other DevOps duties are very new to me.
It's good idea to reload php as well as migrate new tables :)
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.3-fpm reload
php artisan migrate --force
If you're using DigitalOcean and you have $12 to spare you could use ready tools such as Laravel Forge :)
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.
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.
Homestead randomly stopped working for me, so I tried to remove the whole thing and reinstall, but it's not gone well.
I have it "running" after a day and a half of muddling my way through various issues. However, for reasons that I cannot understand, my Homestead box is now running PHP 7.
The instructions I was following had optional options for installing PHP 7, but I intentionally skipped that because we are on PHP 5.
For the life of me, I can't figure out how to fix this. Things I have tried:
I have destroyed and reinstalled the box multiple times.
I have deleted the VirtualBox box multiple times and redownloaded it.
I tried installing v0.3.3 of the box based on one suggestion. (I also updated the homestead.rb script accordingly.) At one point, something failed during the install process with php7.0-fpm: unrecognized service and the configured sites were returning 502 Bad Gateway errors.
After reinstalling with v.0.4.0, it has started "running" as I described (serves the sites as expected, etc.), but with PHP 7.
Searching for solutions has persistently led to a dead-end.
I'm just a dummy front-end developer. :) Laravel, Vagrant, Homestead, all this stuff makes my head hurt. I just want this to work again so I can go back to my actual work. Any advice or alternate avenues of pursuit for researching this problem would be appreciated.
I've been through this issue too and I solved it by installing an old homestead box v0.3.3 and I've used an old release of homestead installer, so I suggest that you remove your current box v0.4.0 and delete your homestead folder then do this:
$vagrant box add laravel/homestead --box-version 0.3.3
and then download an older version of Homestead installer from git, I'm using v2.1.8 it works fine.
Enjoy php 5.6 :)
I had a similar problem where I tried to upgrade Homestead to the most recent Homestead 7.0 box and configure it to run PHP 5.6 instead of PH7, which various sources said was possible via adding a line to the .yaml file specifying the PHP version.
sites:
- map: myproject.local
to: /home/vagrant/Code/craven/public_html
php: "5.6"
What actually happened when I tried that was that I got a 502 CGI gateway error. Here is a summary of the steps I had to take to fix it:
1) SSH into the Homestead virtual machine.
ssh vagrant#127.0.0.1 -p 2222
Taking a look at the nginx error log in /var/log/nginx/ reveals that the PHP 5.6 files the server is looking for don't exist.
You can get confirmation of this by having a look at the executables.
ls -la /usr/bin/php*
2) To install PHP 5.6, run
sudo apt-get update
sudo apt-get install php5.6-fpm
You can confirm that the php 5.6 service is running via the command
service --status-all
3) Once all this is working, refresh the web page for your site and it should now work. In my case, because I was running a Laravel 4.2 site, I then to install Mcrypt:
sudo apt-get install php5.6-mcrypt
4) In order to get my mysql database up and running, I also had to install mysql.
sudo apt-get install php5.6-mysql
And of course after all that, I had to re-import the database contents from the file I'd exported before upgrading the Homestead box.
Note that if you ever destroy and recreate the Homestead box, you will need to repeat all these steps again.
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.