How to Setup Laravel 4
videos

How to Setup Laravel 4

Tutorial Details
  • Difficulty: Intermediate
  • Completion Time: 15 Minutes

As you may know, here at Nettuts+, we’ve covered the popular Laravel framework a great deal. With version 4 on the near horizon, I’ve received quite a few emails and comments, requesting a screencast that describes exactly how to clone and work with the alpha version of Laravel 4, as well as Composer. Hope this helps!


Choose 720p for best clarity, or download this screencast.

In Closing

Laravel 4 is expected to be released in early 2013, likely quite near the first ever Laracon. Stay tuned to Nettuts+ for more information on its release!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://rommelxcastro.com/ Rommel Castro A.

    awesome! thanks!

  • http://twitter.com/sachitandukar Sachit Tandukar

    No offence but is it nettuts so interested in Laravel 4, that they haven’t posted anything about codeigniter v3.x?

    • Marcin

      There is codeigniter 3.x release now available ?

    • http://www.facebook.com/gottier Brian Gottier

      CodeIgniter 3.X has a license that doesn’t work for me as a professional developer. You really need to read the OSL license carefully and understand what it means for you and your business. I’ve used CI for more than 3 years, but can’t use 3.X. Notice I am not promoting another framework, I’m just pointing out that the new license doesn’t work for me and the type of clients I currently do business with. CodeIgniter already seemed to be “growing” into the framework of utter newbs, and I can’t imagine that any professional dev will be using it anymore. It was fun while it lasted.

      • Marcin

        What exactly ?

    • kapil verma

      IMO, everyone should be much, much more interested in L4 than CI3 , simply because L4 pushes php forward a lot, and makes modern php development easy and accessible to a lot of devs

    • jeff_way

      The best I can do is attempt to steer the Nettuts+ community in the direction that we feel is best. We’ll still cover CodeIgniter, but I’d prefer to put the weight of our PHP framework coverage into Laravel.

    • http://twitter.com/jontybehr Jonty Behr

      Why on earth would you want to use CI? Its horribly outdated technology. Coming from a long term CI fan btw.

  • dlpetrie

    Keep in mind that Laravel 4 isn’t even in beta yet… so there isn’t much support for it yet.

  • YehonatanTs

    Not related to the tut but how for god sake I pass a callback to a php function?
    And please don’t refrence me to php.net
    Thanks!

    • IanSimmons

      How about referencing you to sitepoint and stackoverflow? :-)

      // This function uses a callback function.
      function doIt($callback)
      {
      $data = acquireData();
      $callback($data);
      }

      // This is a sample callback function for doIt().
      function myCallback($data)
      {
      echo ‘Data is: ‘, $data, “n”;
      }

      // Call doIt() and pass our sample callback function’s name.
      doIt(‘myCallback’);

      http://www.sitepoint.com/forums/showthread.php?336758-example-of-a-callback-in-PHP

      http://stackoverflow.com/questions/48947/how-do-i-implement-a-callback-in-php

      • YehonatanTs

        And how can I pass function like this? – someFunction(function hi($text) {echo “hi” . $text; });
        Thanks! :D

      • IanSimmons

        I don’t want to continue this to much here since it’s not the topic of Jeffrey’s post. But maybe this will clear things up. You need to pass a string as the first param and anonymous function as the second and someFunction() needs to be defined to put the string and function together, call it, and return the value.

        Like this:

        <?php

        //first define 'someFunction()' to put the string and the anonymous

        //function together as a function call

        function someFunction($text, $callback){

        return $callback($text);

        }

        //then when using it, pass the string as first parameter

        //and the anonymous function as the second parameter

        echo someFunction('programmer dude', function($text){

        return 'hi there ' . $text;

        });

        //outputs: 'hi there programmer dude'

        //you can redefine the string and anonymous function passed

        echo someFunction('fred', function($text){

        //using php built in functions to get return value this time

        return ucfirst($text);

        });

        //outputs: 'Fred'

        I’m not sure of another way to do it.

      • IanSimmons

        //first define ‘someFunction()’ to put the string and the anonymous

        //function together as a function call

        function someFunction($text, $callback){

        return $callback($text);

        }

        //then when using it, pass the string as first parameter

        //and the anonymous function as the second parameter

        echo someFunction(‘programmer dude’, function($text){

        return ‘hi there ‘ . $text;

        });

        //output: ‘hi there programmer dude’

        //allows to redifine the string and anonymous function passed

        echo someFunction(‘fred’, function($text){

        //using php built in functions to get return value

        return ucfirst($text);

        });

        //output: ‘Fred’

      • YehonatanTs

        Thank you so much!

  • IanSimmons

    Great that you went ahead and posted a video intro. I had figured it out from Chris Schmitz’ written article but it took me 30 minutes to find that article.back when I was messing with L4 for your Backbone series.

    I notice this method installs some things by default that may not be needed such as doctrine and swiftmailer. Do you know if there are plans on allowing more customization of the basic install to make it even smaller or are these built in as part of the basic framework?

    • http://twitter.com/PhillSparks Phill Sparks

      The last time I checked L4 doesn’t depend on “Doctrine” but rather one of its common modules. I can’t speak for swiftmailer though, I would imagine that it’s a secondary requirement that may be possible to remove.

      The important thing to remember however is that although the code base might be slightly heavier, only components that you use (directly or indirectly) are actually loaded during run time. So if you never send an e-mail the swiftmailer code won’t be loaded.

      • IanSimmons

        Thanks Phil, I found it had been mentioned on Talyor’s twitter a while back (the idea of a laravel lite) http://twitter.com/taylorotwell/status/233003012715606017. But as you say, the code isn’t loaded if I don’t use it. So it’s not hurting anything other than taking up 25MB of space which probably isn’t likely to be an issue.

  • http://brocknunn.com Brock Nunn

    Wow, that was cool Jeff. I am becoming more and more interested in Laravel. Currently I have a few Rails projects, but with existing PHP knowledge, I can see how valuable a framework like Laravel could be to a team. The conventions seem so simple, and the code seems to be pretty minimal as well.

  • Simon

    Really nice tutorial Jeffrey!!

  • simon

    i got this error

    #!/usr/bin/env php

    Some settings on your machine make Composer unable to work properly.

    Make sure that you fix the issues listed below and run this script again:

    The detect_unicode setting must be disabled.

    Add the following to the end of your `php.ini`:

    detect_unicode = Off

    A php.ini file does not exist. You will have to create one.

  • http://www.wordpressguru.com.au/ Wordpress Developer Sydney

    Thanks Jeff … Honestly I learnt more than from you than my years in Uni … I trust you blindly to suggest and recommend us to new technologies.

    I am planning to learn bit of Laravel and Backbone over the break time. Time to learn a new framework.

    And by the way can i publish the video on my blog. Please recommend.

    • jeff_way

      Thanks! And, yes, you’re free to embed the video. A link back to this article would be appreciated, though.

      • http://www.wordpressguru.com.au/ Wordpress Developer Sydney

        Thanks Jeffery fro the information … cant wait to see more of laravel tutorials in the future

      • http://twitter.com/R_Kylia Kylia

        what’s terminal theme are you using? please

    • pixelBender67

      I agree, Jeff you taught us well

  • http://profiles.google.com/sas1ni69 Hassanin Ahmed

    How different will Laravel 4 be compared to Laravel 3? I would like to start learning the framework. Should I wait? Or should I learn 3 first? Then move to 4? What do you recommend?

  • Sergey

    Yii is better

    • Carl

      Care to elaborate? – I am currently deciding on the framework for my next project and Yii could be considered. Though every time I see a user of Yii mention it, it is normally just to say “It’s better”, just like you have.
      Though they seem too shy (arrogant?) to explain why.

      • Quip

        Well. Yii has huge amount of components and documentation. Easy and clear structure, which allows you to make widgets/modules in a pretty manner. We’ve made a very large e-commerce platform using Yii, and with all this Agile_And_Blabla management panic being around, I must say, I should thank Yii for providing us with _Oh damn, we’ve broken this one, ah, Yii has a solution_ help. Its activerecord, which has scopes/namedscopes, behaviours, events and stuff helps out really serious, and when all the hell breaks loose, Yii’s DAO can be used. The only weak part has been Yii’s simple form management, though great extensions been brought to solve this problem(?). I personally do like Symfony2, but, to be honest, if the job needs to be done, and done extremely fast, Yii kicks in right in time.

        And yeah, Laravel is awesome, though I just read the docs, without writing a line of code in it.

  • Christoph

    Since there have been a lot of tuts on Codeigniter here on Nettus+, i would also be interested in differences to Laravel. I have done a few projects in CI in the past and need a php framework now again. I was about to dig in CI again, before i heard from several people to take a look at laravel. In the past it felt like there was great community for CI, but not that much support from the business behind CI. What do you think Jeff?

  • OriLevi

    If i’m using L3, it will be possible for me to upgrade to L4 without any problems? Or it’s not related to L3?
    Thanks

    • jeff_way

      I wouldn’t worry about upgrading the project just yet. L3 is stable with plenty of documentation.

  • KarmicDice

    It is good that we have a framework that *pushes* the core scripting language or makes use of it efficiently. But, still there is a question mark, when we want to develop a large application, which would mean less changes and more support. Which is why, people prefer ubuntu x.04 releases which has LTS (long term support). I am wondering, had my decision of making a social network on Laravel2 , in year 2011 and by now, I would have finished it when laravel4 is on the verge of releasing stable. How would I get developers who would still be on Laravel2? Drupal is lagging in the league of ‘serious’ and ‘huge’ development due to its concept change with every release following 6 to 7 and now 7 to 8. However, considering 4 releases in 1 year is a sign of not so good stability but, again leveraging with emerging technologies is also quintessential. The question is, How do we manage this thin line?

  • vidma

    The bigest progress learning Laravel I got with ‘Practical Web Application’ by Andrew Perkins. It opens your eyes. More ‘Practical’ and we pay for it.

    • Xr000t

      the 10 video series was so clean and andrew knows his stuff very well .

  • http://twitter.com/MichMich Michael 

    Hey jeff_way, which terminal (theme) are you using? It looks awesome! :)

  • Arman

    And again no any Yii coverage….
    I really like Laravel, but my team is already working on Yii, and Yii is great choice too. Yii has the most stable release cycle, that is appropriate for any big project. It incorporates all the new stuff from PHP but with less harmful migration than any other framework. And with Yii 2.0 coming soon, it will become better.
    But why nettuts is not covering Yii either?

    • Sergey

      Yes, very interesting, why?

    • Quip

      maybe cause Yii’s site isn’t that fancy :)

    • Reine

      coz laravel is illuminati product

    • maurospage

      I really like laravel, even over yii. But it’s clear that this site is sponsoring laravel for some reason. No article on symfony, codeigniter, cakephp ecc.

      It seems like tutsplus is pushing us to laravel. I cant know if there is some buisness logic under this, but that’s what I think.

      Again, I really like laravel. And I thank tutsplus for letting me discover it.

  • The Shift Exchange

    FYI – I just did this tutorial today – and L4 automatically detected Dogs controller – I didnt need to dump anything

  • http://www.facebook.com/profile.php?id=100001057044246 Hamlet Muradyan

    Yeah! It’s very fine! Thanks for this tutorial!

  • pixelBender67

    I’m new to PHP frameworks in general, I took Jeff’s advice and stayed away from frameworks for the first couple of years, Laravel to me is the bomb, keep them coming Jeff!

  • simon

    it will be nice with a quick start video, where we can see the new functions etc. im thinking about the new blade template, i cant find out what the new functions name for “@section” is, because in L4 they use another name for that

  • http://www.facebook.com/mittul.chauhan Mittul Chauhan

    very good tutorial ..

    i m a regular reader of your site .

    i have a one request for you if you accomplish this.

    i
    wanna learn what is Callbacks in mysql .. how to use it .. i wanna
    learn it from you ..you have covered almost everything so far except for
    this i suppose.. if you can do this for me .. i would be thankful ..

    mittul chauhan ….

  • http://twitter.com/joey89924 joey

    It was fun while it lasted.
    S8050

  • equan_pr

    L4 with composer and much simpler directory structure than L3….love it!. Hope there will be another videos or tutorials that show new features of L4. Thanks Jeff!

  • krim belkacem

    can we use laravel if we don’t know OOP in PHP?!
    thank you

    • Philip Damra

      It would be well worth your time to learn OOP in php. There are plenty of great articles on this site covering this information

  • http://www.facebook.com/profile.php?id=100001057044246 Hamlet Muradyan

    How can I use “store” method in controller for admin panel? That’s not allowed POST requests.
    There is a route for this action:
    Route::resource('/admin', 'admin');

  • magemaster

    Hello, html.php was removed from laravel 4? What is the replacement?

  • http://www.clippingpathcenter.com/clipping-path-service.php mamun

    Fantastic! Thanks to share

  • http://www.graphicexpertsonline.com/clippingpath.html mam_raj07

    wow nice and superb…
    Thanks to share..

  • i jones

    how to setup laravel4 on live server eg. pagodabox / appfog / openshift ?

  • ben

    is ‘php artisan key:generate” removed in laravel 4? How you generate an encryption key for /app/config/app.php ??

  • Jared Hocutt

    Out of curiosity, what resolution do your record your screencasts at?

  • Томица

    Jeffrey would you please be so kind to tell me what is your Sublime Text colour scheme in this video?

  • Johan

    Thanks Jeff for this tutorial.

    The link https://github.com/illuminate/app sends a 404. Does Laravel 4 changed name alraeady? I’ve searched for another link, and I found this : https://github.com/suenkang/app.

    But, composer.json was like :

    “require”: {
    “illuminate/foundation”: “>=1.0.0″
    }

    So, it’s not the same as in the tutorial.
    And of course, the “Hello world” example sends an 500 error: 127.0.0.1:42596 [500]: / – Class ‘IlluminateFoundationLightbulb’ not found in /home/johan/l4/start.php on line 19
    Do you know how I can install the right version of illuminate / laravel 4?

    Thanks

    Johan

  • RomanTsjupa

    I really dislike static functions being called everywhere. And it does seem to be slower then most frameworks according to benchmarks. You could try using http://phpixie.com as an easy lightweight framework, with practically no configuration files needed.

    • http://twitter.com/alexmglover Alex Glover

      The static methods are not true static methods. They are facades.

  • Alan
  • http://www.facebook.com/scottmmcpherson Scott McPherson

    Great tutorial! Any time frame as to when we can expect some more laravel 4 tuts?

  • Phillip

    Hi jeff..

    done cloning laravel, but i can’t find composer.json on my laravel directory..what do u think is the problem?

  • mojo706

    Its still taking a while even now (using composer) :( but it did work thanks :D !

  • john

    this is not useful at all….

  • Manuel Pedrera Jiménez

    It seems that the github repository (illuminate/app) used in the video is no longer available. Anyone knows where can Laravel 4 be downloaded from?

  • Dirk Postma

    I guess https://github.com/laravel/framework is the new location for laravel 4. However, in this git repository, there exists no public directory. After running composer install, there still is no public directory. In the docs, http://four.laravel.com/docs/installation, they mention an app direcotry. That also doesn’t exist.

    The only folders I have after running “composer install” are:

    build
    src
    tests
    vender

    I didn’t get any errors. What am I doing wrong?

    • Dirk Postma

      To answer myself:

      The used git URL is wrong. You can either:

      1. Follow instructions on http://four.laravel.com/docs/installation

      This uses a zip-archive that’s (I guess) build every few days.

      2. Clone the develop branch of laravel and then run composer install:

      $ git clone -b develop git@github.com:laravel/laravel.git

      $ composer install

  • josh

    looks like the git hub link doesn’t work anymore,

  • hardevin

    laravel is backbone of backend..;)