📜 ⬆️ ⬇️

Installing Laravel 5 on Windows XP, creating a project and deploying a project on Heroku

Hello.
The other day, for some reason, I had to install the php framework Laravel 5 (dev version) on the good old Windows XP x86 (x32).
The experience is not familiar to me, as I didn’t have to use the latest version of php, but for a beginner, the article may be useful.
So, if you were faced with the task (yes, at least for the sake of experiments during working hours on the old platform) to install the dev-version of the Laravel framework, then this article can be very useful. Welcome!

Why the dev version? I was inspired by the description of laravel 5 in the article " What's new in Laravel 5 ", thanks to Cubist .
First you need to install a local server, I chose the XAMPP assembly - quickly, conveniently, nothing to complain about with intel celeron 430 (1.80 GHz) with 2 GB of RAM on board.
Please note that you need to download version 1.8.2, which includes php 5.4.31 (since this is exactly the version of php that will work on win xp).
Separately, PHP version 5.4 can be downloaded from here: windows.php.net/download/#php-5.4

After installing the server, we turn to the documentation of Laravel . We decide that for installation we need composer, which can be downloaded from here: getcomposer.org/download

Composer


During the installation process, carefully reading the dialog boxes, specify the path to the folder with PHP:
Setup Dialog
image

I installed xampp on drive D, make sure that the line contains the correct path, and if not, change it to the path to the xampp / php folder.
')

Laravel installer


After installing the composer, you can proceed with the installation of the framework itself. To do this, type the following at the command prompt:
D:/> composer global require "laravel/installer=~1.1 

This command downloads the laravel installer to your computer.

Immediately after this, you will need to add a new environment variable (My Computer -> PCM -> Properties -> the Advanced tab -> Environment Variables button (below) -> select the Path variable -> Change button.

In my case, the path to the downloaded laravel installer looks like this:
From: \ Documents and Settings \ Heafy \ Application Data \ Composer \ vendor \ bin
(Do not forget about the semicolon that separates the environment variables. For clarity, I would recommend copying the entire value of the variable into notepad ++, and changing it there, then return it changed back to the "Variable value" field).

Let's run the check at this stage, open the command line and enter only one word in it: laravel
If you’ve done everything right, then the installer’s version and possible commands will appear on the command line:
The result of the laravel command
image

If otherwise, ask in the comments, on the toaster, write to the post office or use another type of communication.

Creating a project Laravel 5


Everything is ready to create and launch the first project using Laravel, so what to expect, using the command line, navigate to the xampp / htdocs folder:
 D:/> cd D:/xampp/htdocs 

And create a new project with the command:
 D:/xampp/htdocs> composer create-project laravel/laravel <i></i> dev-develop 

Pay attention to the dev-develop, this is what allows you to create an application using the version of Laravel 5 (develop).

The application is ready, let's check if we did everything right.
In the command line, go to the folder of the created project:

 D:/> cd  

And run the server:

 D:/xampp/htdocs/ProjName> php artisan serve 

Let's go to the address localhost : 8000 and see the standard page of the application laravels, indicating the successful installation.

Github


For a github (register an account, if not yet - it's time to start), install it on your computer, go to the project folder in the command line with the command:

 cd D:/xampp/htdocs/ProjName 

And we prescribe in turn the teams proposed to us by git:

 git init git commit -am "first commit" git remote add origin https://github.com/[AcauntName]/[RepName].git #  ,         git push -u origin master 

You will be asked to enter your login and password, after which files and folders will be downloaded to the github repository. (Be sure to check that this happened by going to the repository page in the browser).

Heroku


This will allow us to test our applications for free on production, without unnecessary problems.
After the project has been copied to the githab, you need to:

- Register an account: id.heroku.com/signup
- Download and install Heroky Toolbelt: toolbelt.heroku.com

At the command prompt, enter the command:

 heroku login 

Enter your email and password.

Next, we will prepare the project, namely, delete the line “composer.lock” from the .gitignore file (which is in the root folder of the project) and in the file composer.json. Replace the lines:

 "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, 

On the following:

 "scripts": { "post-install-cmd": [ "$_ artisan optimize" ], "pre-update-cmd": [ "$_ artisan clear-compiled" ], "post-update-cmd": [ "$_ artisan optimize" ], "post-create-project-cmd": [ "$_ artisan key:generate" ] }, 


Create a file in the project root with the name Procfile (the register matters!), With the contents
web: vendor / bin / heroku-php-apache2 public

Is done.

Run the command from the command line (being in the root of the project):

 composer install 


Let's update the repository (after all, the project will be copied from it to the heroku server) and we will upload the project to heroku with the following bundle of commands:

 git add . git commit -am "deploy on heroku" git push git heroku create git push heroku master 


Everything. It remains to check the performance.
Enter the command:

 heroku open 

In the browser (the one installed by the default browser), a tab with the Laravel welcome page of your new project created using Laravel version 5 will open. Its name (it is also the address) can be changed in the profile settings in your account on the heroku website, or by command. For available commands, see the heroku documentation .

Thanks for attention!
Do not forget to visit Laracasts and help beginners on the Toaster .

Source: https://habr.com/ru/post/239079/


All Articles