Oct 8, 2013

Laravel 4: Setting up and basics

This guide will go through one method of setting up a basic Laravel 4 environment. There are quick-start instructions, however in this guide we are not going to rely on a pre-installed global Composer binary.

These instructions require that you have git installed.

Installation

  1. Clone the laravel framework repository. This contains a basic layout for an application, although composer will be required to install all the dependencies.

    git clone https://github.com/laravel/laravel.git
  2. Rename the directory to one more suited for your project

    mv laravel/ [project]
  3. Change the permissions and owner of your project

    chown -R [user]:[group] [project]
  4. Go into your project directory

    cd [project]
  5. Download a copy of composer for your project

    curl -sS https://getcomposer.org/installer | php
  6. Since composer will now handle all dependancies, we no longer need git to mirror the laravel repository. Remove it:

    git remote -vgit remote rm origin
    If you wish to keep the repository around, you should just rename it:

    git remote rename origin laravel
  7. Edit your composer dependencies, which are stored in composer.json. If nothing else, edit the name, description, keywords, and license fields to suit your project.
  8. Ensure your composer.json is valid by running:

    php composer.phar validate
  9. Install all dependancies via composer

    php composer.phar install
  10. Run the in-built PHP development server to check that everything is working correctly

    php artisan server

    You should now be able to view your new application through http://localhost:8000/. Use the --help flag to see more configuration options.
  11. If you make changes to your composer dependancies, just run:

    php composer.phar update

Netbeans and Laravel set-up

  1. Follow the above instructions to create a new instance of Laravel
  2. Start a new project by clicking on File -> New Project
  3. Select PHP -> PHP Application  with existing sources
  4. Select the sources folder as the project directory you created earlier
  5. Set the 'Run As' configuration as PHP Built-in Web Server with the router script set to public/index.php. Note that other files (such as css and js files) stored in the public directory will not be served.

Eclipse and Laravel set-up

  1. Ensure you have installed the PHP development extensions
  2. Select File -> New Project -> Project
  3. Select PHP -> PHP Project
  4. Enter in a project name and choose the existing source folder. You can finish the settings now, or configure the project further.
  5. I could not get the Eclipse PHP server to work, so you will have to figure that one our for yourself.

Composer overview

  • The command php composer.phar will list all the available commands in composer
  • The composer.json file will list dependencies and configuration defaults for the composer binary.
  • The composer.lock file is generated after you run the install or update composer command. This file will store the exact version downloaded and any local configuration.

Resources

1 comment:

  1. you can install laravel by three method,
    composer,
    clone the git
    user laravel.phar file.

    http://kvcodes.com/2014/04/install-laravel-using-laravel-phar-file/
    read for more informations.

    ReplyDelete

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!