Install Laravel 5 on Windows XP, create a project and deploy the project to 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, since I had to use not the latest version of php, but for a beginner, the article may be useful.
So, if you were faced with the task (even for the sake of experimenting 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 Cubist .
First you need to install a local server, I chose XAMPPassembly - fast, convenient, nothing to complain 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 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 Laravel documentation . We decide that for installation we need composer, which can be downloaded from here: getcomposer.org/download

Composer


During the installation, carefully reading the dialog boxes, we indicate the path to the folder with PHP:
Installation 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 composer, you can start installing the framework itself, for which, at the command line, enter the following:
D:/> composer global require "laravel/installer=~1.1

This command downloads laravel installer to your computer.

Immediately after that, you will need to add a new environment variable (My computer -> RMB -> Properties -> Advanced tab -> Environment variables button (bottom) -> select the Path variable -> Change button).

In my case, the path to the downloaded laravel installer looks like this:
C: \ 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 in notepad ala notep ++ ++, and change it there, then return it changed back to the "Variable value" field).

Let's check at this stage, open the command line and enter just one word in it: laravel
If you did everything right, then the installer 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 mail or use a different type of communication.

Creating a Laravel 5 Project


Everything is ready to create and launch the first project using Laravel, so why wait, use the command line to move 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 ИмяВашегоПроекта dev-develop

Pay attention to 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 whether we did everything right.
In the command line, go to the folder of the created project:

D:/> cd ИмяВашегоПроекта

And start the server:

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

We will go to localhost : 8000 and we will see the standard page of the application’s laravel, indicating a successful installation.

Github


For github (register an account, if not already, it’s time to get started), install it on the computer, at the command prompt, go to the folder of our project with the command:

cd D:/xampp/htdocs/ProjName

And we prescribe in turn the teams proposed to us by the 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 a username and password, after which the files and folders will be downloaded to the repository on the github. (Be sure to check that this happens by going to the repository page in the browser).

Heroku


This will allow us to test our applications on production for free, without unnecessary troubles.
After the project was copied to github, you must:

- 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, prepare the project, namely, delete the line “composer.lock” from the file .gitignore (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"
		]
	},

To 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 root of the project called Procfile (the register matters!), With the contents of
web: vendor / bin / heroku-php-apache2 public

Done.

Run the command from the command line (at the root of the project):

composer install


Update the repository (after all, it is from him that the project will be copied to the heroku server) and upload the project to the Heroka with the following command pack:

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


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

heroku open

In the browser (the one installed by default by the browser), a tab opens with the Laravel welcome page for your new project created using Laravel version 5. You can change its name (it is the address) in the profile settings in your personal account on the heroku website, or by the team. See the heroku documentation for available commands .

Thanks for attention!
Remember to visit Laracasts and help beginners on the Toaster .

Also popular now: