https://github.com/hillelcoren/invoice-ninja is a great resource :)
'Real Life' L5/L5.1 app example
Laracasts videos are obviously useful without a doubt. But I'm sure many will agree that nothing compares to a working example of a functional code.
Do any of you guys have an open source example of an already deployed L5/L5.1 app which you would like to show off? Being an example learner myself, I learn a lot by exploring examples rather than focusing on theory.
Things of particular interest would be:
- Middleware;
- Custom authentication methods (including third party packages);
- Testing;
- JS frameworks (such as Angular or Vue);
etc.
@pyxl wow this are lots of namespaces :D -> https://github.com/hillelcoren/invoice-ninja/blob/master/app/Http/Controllers/InvoiceController.php
Checked this "invoice-ninja" project, it's written mostly in a bad way, just look into routes file http://screencast.com/t/8EO1eFcZvJZ , they have put there tons of definitions, list of credits cards vendors http://screencast.com/t/hQtSfSTb , some functions. I would recommend not to get this project as an example of clear code. Also they never use Requests validations, while I was scrolling code I noticed tons of possible bugs, like using route resource on one function http://screencast.com/t/OFnqYW9Ame , they have to replace it with Route::post , and so on. Also this project don't use any custom Service providers, some wierd files http://screencast.com/t/oC1ImxfA1lh with wrong opening tag and not PhpDoc commets. Also they use Grunt, don't use elixir, all their JS is adder directly to public, while some others are build with Grunt from vendor that's also right in public folder. No any test PHPUnit test cases. So I don't recommend this project as an example.
@vedmant yeah and some html code in controllers :) https://github.com/hillelcoren/invoice-ninja/blob/master/app/Http/Controllers/InvoiceController.php#L153-L163
So the code quality is not the best, but if it works why not :) Didnt covered the complete code or tested the app yet.
@tomicakorac , check the source of Larabin (https://larabin.com/) :
https://github.com/Kryptonit3/LaraBin
which @Kryptonit3 providet - kudos to him.
Thanks @all for the examples. I've seen LaraBin before and it's very useful. Thanks to Kryptonit3 from me as well. Although I was hoping to see a few more code bases.
@hostianer good example of Single responsibility principle, lol
Maybe the code of Laravel.io will get you some ideas!
Thanks @Ruffles . I didn't know Laravel.io was available. It doesn't seem to be L5 though, but it's very useful nonetheless.
Hi @tomicakorac see the following link:
As showing off someone's APP can be quite involved and the Laracast video's do not generally center on theory per say. I would suggest the following:
- Install a clean Laravel 5.1.
- Install a clean Laravel 5.0 in another directory.
- For some insane reason the base Authentication example is missing from 5.1
- Follow the upgrade instructions for 5.0 to 5.1. You will have to move code from 5.0 install to 5.1
- You can then see an example from soup to nuts.
You can use the theoretical video's to fill in some gaps.
This will also give you practice in using Composer. Learn the Composer Fire Dance and show your tribute him/her. Composer will reward you by granting most update requests :} Don't be greedy and try to require too many packages at a time. Composer will reward you with the 'Red Screen of Confusion'!!! I recommend PHPStorm to code in. "Teach a Man to Fish..." Blah Blah... Typing code is good for the fingers and helps muscle memory...
One of the best sites build with laravel: https://laracasts.com/ :)
@jimmck I may still not be an artisan-level programmer, but I do know my way around building a basic small to middle sized app. I've learned all that thanks to tutorials from the most various sources around the Internet. I'm also pretty comfortable with Composer. But now I'm after just a bit bigger prey.
I like to compare programming with the game of chess, although you can compare literally anything you do with chess by the same analogy: The rules of chess are simple enough for anyone to learn them. It's very easy to learn which figure does what. But to become a true chess master, it takes exponentially more experience and real life practice.
Well, the same goes for PHP, in my opinion. I feel I'm on the border between knowing what all the functionality does and how it all works, and how to compose a beautiful symphony for that discorded orchestra.
And from my personal experience I know that there aren't many ways to learn that lesson. Except to have a first person encounter with as many good examples as possible. I think that's why Jeffrey also tries hard to show in his series real world examples that he's building. But no matter how useful his examples are, one person will always teach you less than two. And two people will teach you less than three people etc. So I just thought I'd ask for some more examples, namely about Events and Listeners, Middleware, managing multiple third party packages etc.
@tomicakorac Well said ;)
This invoice-ninja is a worst example ever.
If it shows anything, then it would be "How to NOT write any application!"
@keevitaja that's also useful :)
@tomicakorac I am in Awe of You Sir! You can learn by watching not doing! Bobby Fischer learned by playing countless games,of chess. But Watson, like you need only to be fed the input of others. In Awe Sir, I am truly humbled.
Ah you are in luck @bestmomo has a sample example here
It's not a real life example ;)
@jimmck :D I couldn't agree with you more. My intention was never to just look at someone else's completed work and not do anything else. It's just that it isn't that easy for an inexperienced guy to presume how useful a piece of code is, as we've seen on the Invoice Ninja example after all. If it wasn't for all the guys' input, I would probably not have much doubt in that code, and would try following its example in my own work.
EDIT: My point is, you probably got me wrong if you think I could learn by just watching. It's actually on the contrary.
@keevitaja why is invoice ninja bad?
This code is not following a single solid principle, which makes it very hard to maintain.
https://github.com/hillelcoren/invoice-ninja/blob/master/app/Http/Controllers/InvoiceController.php
Controller should be a hub between user and framework. In this example the controller is the framework.
Also it is not using Laravel has it is intended to be used. Check routes.php . There some really weird define's in there. And it just one example of the weirdness of this project.
https://github.com/hillelcoren/invoice-ninja/blob/master/app/Http/routes.php
But everything above does not say that this cannot work. It is just a bad example on how to code Laravel app!
Edit: My goal is not to troll this project or it's creators. They have invested a great deal of their time into it.
that routes file looks really weird
@tomicakorac I'm using middleware parameters and vue with laravel
It all works well, should clean it up a bit but I'm quite busy. I learned a whole lot from laracasts lessons over the year. In another private project I'm using Cartalyst Sentinel https://cartalyst.com/manual/sentinel/2.0 The only thing I have to do there is extend my User Model with their EloquentUser Model, same for Role model and it all works fine.
https://github.com/jonasvanderhaegen/jonasvanderhaegen.be/ http://j.mp/vdhjonas-todo
@tomicakorac @mattstauffer has created an open-source application with Laravel 5.1 that texts a predefined contact if you get pulled over by the police: https://github.com/mattstauffer/pulledover/
It looks like the whole app's code is only in the routes.php file :D
@martinbean sounds interesting :) But are you allowed to record voices from other people who doesnt know they are recorded? ^^
@kayyyy I’m not sure about American law. It’s also not my project.
In defence of the Invoice Ninja developer, (I am not he) he may have come from a procedural background. My first website developed with Codeigniter looked a lot like that, with duplicated code, and everything shoved in the controller or model because i had no idea where to put it.
Has anyone mentioned Laravel Tricks yet? https://github.com/CodepadME/laravel-tricks
EDIT: Oops. Laravel Tricks is a 4.1 site, not 5/5.1. Still worth looking at though.
Please or to participate in this conversation.