RastcodeS

Where we take good care of both your front and back-end needs

Great place to take your code to the next level

Checkout my work and get in touch



RastcodeS Logo
Go Back

Laravel Starter App - How I made this app Part I


Laravel PHP



Written by Rastko

date - 22/Aug/18 | views - 461

Laravel Starter App - How I made this app Part I

     Laravel starter application will help all, who are new to this PHP framework, get a clear understanding of how to initialize a new project, setup a local configuration for easy development and run a few artisan and npm scripts to get you started.

     This is the first in a series of posts, describing the full development of a Laravel app.

 

Prerequisites:

     Knowledge:

  • Basic understanding of PHP

  • Basic understanding of HTML, JavaScript and CSS

  • Basic understanding of relational databases

     Tools:

  • An Apache distribution ( I'm using XAMPP  - installation is pretty straightforward )
    • Note for those comming from Java - If you're getting an error concerning MySQL, you might need to terminate MySQL Workbench while running XAMPP. We won't be using it anyway.

  • Composer - a Dependency Manager for PHP
    • Again, nothing special about the installation, but if you're using XAMPP, and when prompted to provide a PHP executable, make sure you browse to the one in XAMPP installlation folder. For me, it's in C:\xampp\php\php.exe

  • Since Laravel comes with some useful node modules, it is advisable to have Node.js

  • Text editor, any will do, although I'm using Visual Studio Code, and I highly recommend it

  • Finally, a command line interface for running the necessary, well commands
    • If you're using Visual Studio Code, you get an integrated terminal, which comes in handy

 

     That was a lot, but getting in prepared will save you time in the long run.

 

     Ok, now that you have all the tools for the job, it's time to start your first Laravel application.

 

Step 1 - initialize the app

 

     In the terminal of your choice navigate to the htdocs folder within the XAMPP installation. It will look something like:

/c/xampp/htdocs

    

     Now, initialize the app with the following command:

composer create-project laravel/laravel yourappname

     Note - it will take some time so don't worry about it.

 

Step 2 - create a virtual host for your application

 

     This part is optional, but highly recommended. It will basically allow you to simulate a real host and not serve your application from a public folder, which can be a security risk.

     Here, we have to edit two files:

     First file is httpd-vhost.conf, located in C:\xampp\apache\conf\extra

     Scroll to the bottom and add the following:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/yourappname/public"
    ServerName yourappname.me
</VirtualHost>

     There are other possible parameters available, but for our example these will suffice.

 

     The first line declares the location of a public folder in your application, and the second the name of the virtual server. The server name does not need to end with .me, and in other examples you might find .dev. The reson I included .me is because some people had problems using the .dev.

 

     Now to edit the second file, you need to follow these instructions exactly.

     First, open your Notepad as Administrator (right click - Run as administrator)

     Got to File - Open and browse to:

 C:\Windows\System32\drivers\etc\hosts

     Make sure you have All Files selected instead of Text files, as the hosts file will be invisible. At the bottom of this file add:

    

127.0.0.1 localhost
127.0.0.1 sampleapp.me

     If you already have the localhost, then only the second line is necessary. This process is needed to configure the system host. Save the file and restart Apache.

    

     Now you can open your browser and type:

yourappname.me

 

     You'll be greeted by a welcome page

Laravel Welcome Page

    

     The starter app is done!

     In the next chapter, we'll take a look at the folder structure of a simple Laravel app and also enable styling though Node and Sass.

 


View App/Backend
Login to comment

Comments


No Comments yet. Be the first!

Currently working on a Laravel project

Check it out
Java Break - Declare and Initialize Variables - Java Core Part - VI
Java Break - Declare and Initialize Variables - Java Core Part - VI

     Declaring and initializing variable in Java. How to do it properly and avoid mistakes.

     The sixth chapter...

Java


Recents


Popular