What to Expect From Laravel 4
videos

What to Expect From Laravel 4

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

If you’re keeping up on the latest news in the PHP community, then you likely know that Laravel 4 is on the near horizon. Its creator, Taylor Otwell, recently recorded a handful of screencasts to demonstrate what we can expect, including resourceful controllers, improvements to Eloquent, Composer support, and much more! Take a look after the jump!


Basic Routing and Composers


Controllers and Filters


IOC Container Basics


Controller Injection and Unit Testing


Eloquent Collections and Polymorphic Relations


Closing Thoughts

To stay up to date on the latest Laravel news, be sure to follow them on Twitter. Also, start getting your bags packed for the first Laravel Conference, coming early 2013!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • MPinteractiv

    Nice article. Though i really prefer Silex , which is simpler and has dependency injection at its core.

    • kapil verma

      laravel has a pretty awesome DI container at its core which can auto resolve dependencies, do check it out

    • Zizaco Zizuini

      Silex is nice but it’s micro. And unless your application is gonna be really simple it will not help that much. (ORM for example)

  • Michael

    Thanks for keeping us up to date on Laravel. I’ve only scratched the surface with Laravel 3. In your opinion, Jeffrey, is Laravel 4 a major overhaul or mostly incremental?

    • http://twitter.com/jeffrey_way Jeffrey Way
      Author

      The API is largely the same. So it’s not going to be some massive re-learning experience. But, there’s lots of new stuff to dig into as well.

      In terms of how “major,” well, this will be the largest update that Laravel has had yet.

    • http://nikkobautista.com Nikko Bautista

      With regards to changes in the framework itself, Laravel 4 will be more “modular” rather than a single downloaded framework, via Composer. This makes Laravel more flexible since you can load only the components that you’ll actually need. It also lets you use whatever packages are on Packagist.

    • Devin Sturgeon

      This was a major push by people like Phil Sturgeon and the PHP community Composer to PHP is like Gems to Ruby having the self-updating code base and integrated web server are in the same realm as other languages and i’m glad to see the community come together on this.

  • Peter

    if I work on codeigniter you recomend a switch to Laravel ?
    I’m new on php frameworks , I learn codeigniter it’s cool framework , it’s speed my work so much … Codeigniter is ok or you recomend switch ? … and maby why ?

    thanks for suggesions

    • http://twitter.com/montogeek Fernando Montoya

      Yes, I also started with CodeIgniter, CI is good for a lot of things, but with Laravel you write fewer lines of code to do the same thing.

    • Zizaco Zizuini

      Codeigniter features are designed for legacy PHP and don’t use the most modern/best stuff to “speed your work”. Between Codeigniter and Laravel, for a new/modern project I recomend Laravel.

  • http://www.facebook.com/promehdioh مهدي غازي

    I use codeigniter framework and I will switch to Yii framework
    what you advise me?

    • http://www.facebook.com/kristjanmik Kristján Ingi Mikaelsson

      Laravel 4 looks very promising. I was hardcore codeigniter fan until 15months ago when I made the switch to Laravel. When I look back it is one of my best programming decision over the last few years. You should definitely check it out!

    • http://twitter.com/montogeek Fernando Montoya

      Switch to Laravel 3 for start :)

    • http://twitter.com/djchux Jesus

      I switched from ci to yii about 18 months ago. Never went back, and i never look to another framework. Give Yii a try

    • ahmed mohameed

      Hi Mahdy, I’m also was using codeigniter but now i switched to Yii and it’s amazing, Good step.

    • http://twitter.com/rei_liit John Kevin Basco

      I use CodeIgniter and Laravel depending on the requirement of the project like CI when I need to support PHP 5.2 . Give Laravel 3 a try. You will love it for sure! especially when Larave 4 comes out :) Its damn awesome!

    • http://www.facebook.com/promehdioh مهدي غازي

      thank you,

      I will try working with laravel4

      after that I will switch to yii

      • http://www.facebook.com/glenn.plas Glenn Plas

        Yii has been a big disappointment to me, once I finally got it running (system wise then) what I needed to do in order to get the most simple page constructed (custom js, form, openlayers map), which I already had working in static html. That thing just made me nuts. documentation-wise Laravel is heaps beyond others (for instance phpdevshell). I’ve seen some heated arguements from smart people on the Kohana forums and when checking out Laravel 4 it looked like about half of the issues where addressed or already thought about by the author. That just gives me so much confidence knowing he’s on top of things.

  • Tommy

    What are the pros and cons of laravel compared to codeigniter?

    • Zizaco Zizuini

      Search for PHP Townhall and listen to the 1st episode.

      • Ian

        Great and informative podcast there. Thanks for mentioning that Zizaco

  • Asher

    These look like great videos, but only the first few are at a decent resolution. I find the final ones that are only in 480p almost impossible to follow because I can’t read the text on the screen. Any chance of getting higher res ones uploaded?

    • http://twitter.com/jeffrey_way Jeffrey Way
      Author

      Yeah, the resolution they were recorded at it doesn’t seem to play nicely with YouTube. That’s why I offered download links below the videos.

      • http://www.facebook.com/paolodominict Paolo Dominict Umali

        Why not just link to his videos?

      • jeff_way

        A big site like Nettuts+ would use up all of their available bandwidth.

    • http://twitter.com/usirin Umut Şirin

      You can find everything on http://vimeo.com/user203143 as HD :)

  • Jason

    This is the problem with Laravel. This is why I use CodeIgniter.

    I stopped following Laravel when it was just before version 2. This wasn’t a long time ago. Now its about to hit version 4! The changes between versions are not minor. They are sweeping changes to how you use the framework.

    I work on projects that can take 6 months to a year. In that time Laravel jumped from 1.x to – almost – 4.x. Using Laravel would mean we are either using an outdated version of the framework or refactoring our code every 3-6 months to keep up. Neither solution is optimal.

    This is why myself and my colleagues use CodeIgniter. CI Development is slow and dependable. You know that between when you start and finish any updates will likely be bug fixes.

    Laravel looks great but until they reach a point of stability I don’t think it is worth using on major projects.

    • Younes

      Exactly, still Laravel is great… as FuelPHP is, and which I recommend you to use since you’re searching for a Laravel alternative and you’re a CI user.
      For what reason ? See the documentation & Try it by yourself, give it a chance, do not blindly follow other’s recommendations.

      Note that FuelPHP was made by some guys behind CI

    • Nathan Malcolm

      I spoke to Taylor, and he said that Laravel 4 is the version of Laravel where development will “slow down” in the sense that you won’t see Firefox-style rapid releases. I had my doubts too while considering Laravel as an option for our project but it seems like a stable candidate now.

      • Jason

        I wouldn’t hold your breath, I asked on the forums around the time of the Version 2 about the rapid release cycle and was told that development will slow down and the community will be given a chance to mature and the code base around Laravel to build up. Yet here we are with v4.

      • http://twitter.com/jeffrey_way Jeffrey Way
        Author

        The question is, though, would you want it to really slow down? Assuming that each new version is a significant improvement, I say the more the merrier.

      • Jason

        The problem is that Laravel is Taylor’s project. It isn’t a group project with a number of developers. Whatever is the flavor of the month goes into Laravel. An update may give new ways to do something but it won’t necessarily be a better way of doing of it.

        It is like when Laravel implemented controllers. Suddenly you had two ways to write code that could achieve exactly the same thing. Routes weren’t depreciated. As far as I am aware both methods are still in there.

        I can’t help but feel that the time taken to implement this could have been spend improving something else or making it more efficient. Maybe Slow Down isn’t the correct words. Perhaps it is “more focused” development which I would like to see.

        Of course this is just me. I think Taylor is an excellent developer, its his project and I wish him the best the luck. The way he is handling it though means it isn’t for me or my projects.

    • http://twitter.com/jeffrey_way Jeffrey Way
      Author

      You’re right: Laravel is evolving very quickly – but that’s a good thing! There’s nothing wrong with a project using Laravel 3. It’s not like, as soon as V4 comes out, you have no choice but to upgrade.

      Personally, I’d far prefer a rapid development cycle over “slow and steady.”

      • Jason

        I agree, you want development however with a framework there is a cost. Each change to Laravel is large and sweeping. It is easy to be left behind, for bugs in versions to be missed and it makes it more difficult to get support on an illusive issue if the version you was using only existed for 3-6 months before it was radically altered.

      • Petar Zivkovic

        It is true that this makes for an exciting framework and vibrant community, which are great to have, but not always the best business decision. It really does depend on the project.

        Laravel is amazing! I’ve played around with it a bit, and utterly loved it. That said, I’m not sure if I’d commit to using it just yet for a project that might take 6+ months to develop and longer still to refine… Seems a little to volatile for something like that, still too young.

        Slow and steady isn’t *always* a bad thing.

    • javiervd1

      CI went through this phase as well but it was a while ago you just picked it up when it got more stable, eventually this will happen to Laravel as well as it gets more mature so far I think it’s great

  • Johnathan Barrett

    Is he using Firefox as a joke?

    • http://www.facebook.com/jesus.bejarano.948 Jesus Bejarano

      Are you making a joke?

  • conarw

    It looks like Laravel 4 will be using a lot of composer, I have not used it yet, are there any good resources for getting up to speed on that?

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

    I checked out Laravel4 last week, and using Composer wasn’t difficult, but I hope the framework will have downloads that don’t require Composer. Yes, Composer can be nice, but if some only use it to get Laravel up and running, then it just adds to the initial complexity of getting started with Laravel. I did check out the Packagist website, and there may be other repos, but it’s hard to know what you can get with Composer. There needs to be a better explanation of packages and it shouldn’t be a mystery if a package exists.

  • http://twitter.com/danwhite85 Dan White

    There’s a new one out on Error Handling – http://vimeo.com/53445935

    • Iansimmons

      Nice, thanks for the link. Just added it to my collection :-)

  • Matthew J. Sahagian

    Annotations and reflection are a poor choice in my opinion.

    Reflection certainly removes a step or two in terms of setting up DI containers — but it seems like a rather messy way to handle this. Everyone is doing DI differently in PHP and it’s just going to get messier and messier.

    Annotations, however, are even worse if you ask me. I’m frankly afraid to look at the code to see how this is being done. Although reflection can read a docblock, I’m assuming some custom parsing is then needed to parse this out. Not only am I not a fan of information in comments having any effect on my code, let alone my code relying on them to function properly on an integration level… this raises an even bigger issue with regards to variance…. particularly as more and more frameworks start to use docblock annotation, and these formats are even MORE diverse.

    At least with reflected constructor dependency injection you’re just tying to that container feature… using docblocks has a potential to make your code outright break if used in another framework which does something similar but whose parser breaks on your annotation sytle. Tsk Tsk.

    • Dustin Fraker

      Always nice to hear your positive comments on other people’s work. How’s the user adoption of inkwell going?

      • mattsah

        Thanks. I’m glad you enjoy my feedback. With regards to inKWell, no idea.

    • http://twitter.com/syropian Collin Henderson

      Remember, these annotation features are totally optional. Laravel gives you other ways.

    • http://profiles.google.com/evantbyrne Evan Byrne

      I’m using a very simple docblock annotation-like parser for a CMS I’m currently developing and it works great. It’s a very elegant way to add meta data to classes and properties. If you are worried about breaking a framework’s annotation parser, then just read the docs before you use it.

  • shamim

    Wow great creativity!!!!!!!!!!!!!!!!
    Really fantastic…thanks to share..

  • hasan

    Superb post and its really amazing..
    Thanks to share..

  • http://www.facebook.com/hanushh Hanush H Nair

    What about Laravel vs Yii?

  • http://twitter.com/ridersx Alexandr Kuhta

    Oh, damn it annotations… This disrupts the performance and code readability =

  • zvineyard

    I can’t wait until 4 is out. This looks so promising!

  • Dji

    Give FuelPHP a try. I switched from Kohana (a CI fork) to FuelPHP. Dev time and features implementation were considerable shortened. The doc is good, lot if Kohana features are integrated (templating, DB/ODM drivers, asset management, …).

  • Amir

    Cool stuff going on here, can’t wait for the Laravel 4 final release. thanks a lot for the article.

  • http://twitter.com/codedungeon Mike Erickson

    Why couldn’t all the videos be done like the first one? That is the only one legible (viewing on iPad). All the others are impossible to see – horrible resolution.

    • http://twitter.com/codedungeon Mike Erickson

      Even viewing the direct download links, or from Vimeo site the resolution is way too small. Will have a look on computer this weekend (hope it is better).

  • sdfdvzvsfsdf

    efhgdgkjgert

  • http://www.facebook.com/khalid.elaggan Khalid Zenho

    amazing