Support the ongoing development of Laravel.io →
Views Blade
Last updated 2 years ago.
0

I think view composers are what you're looking for: http://laravel.com/docs/responses#view-composers

Last updated 2 years ago.
0

Yep! Agree with pixel

Last updated 2 years ago.
0

Thanks for the reply guys, I tried using view composers and I got a blank page. What could I be doing wrong?

here's the code on paste bin, because I wasn't sure if I could post it here.

http://laravel.io/bin/32m

Last updated 2 years ago.
0

You don't define view composers in the controller. Put them into routes.php or filters.php or even better in composers.php

There's a good video tutorial on view composers from the great Jeffrey Way :-D http://www.youtube.com/watch?v=X8yqmZtKOoY

Last updated 2 years ago.
0

Ok I followed the tutorial as best I could all the way to the point where he checks his work and it works, but mine don't and this is the error I'm getting:

Class Acme\Repositories\FlatTagRepository does not exist

I have checked all my spelling, even made sure the folder and file were an exact match and I cannot figure out why It's not finding the class. I suspect a typo, but I've checked and rechecked and I can't find any typos.

I pasted the code here:

http://laravel.io/bin/xvK

Last updated 2 years ago.
0

Your code is fine.

Maybe you forgot to do a composer dump-autoload after your edits to composer.json ?

If you're on Windows maybe it's a problem you refer to the application folder app as App in your psr-0 autload

"psr-0": {
	"Acme": "App/"
}
Last updated 2 years ago.
0

I'm running LAMP I am starting to wonder if it's because I'm running Laravel version 4.1. Maybe I should roll back to 4.0 what do you think?

Also, something could be botched in my setup, but everything is stock except for changing the name of the folder and adding views->layouts, so it's hard to believe that would be the case.

david@lappy:~/www/test_laravel$ composer dump-autoload No command 'composer' found, did you mean: Command 'compose' from package 'mime-support' (main) composer: command not found

But.....

david@lappy:~/www/test_laravel$ php artisan dump-autoload Generating optimized class loader

It seems artisan might be what you was referring to?

Last updated 2 years ago.
0

Your code is running fine on Laravel 4.1 so this is not the cause.

I've installed composer globally that why I can call

composer dump-autoload

I think in your case you have to run in the root of your application (where composer.json lies):

php composer.phar dump-autoload

Artisan dump-autload runs composer and does some additional stuff so you should also be fine with this.

So after running php artisan dump-autoload it's still not working ?

Last updated 2 years ago.
0

Ah Ha! That worked. I didn't realize you were referring to that file. I have my composer.phar file in the www directory. Something I should have known, since I had to call composer a few times last week when I first started. I think I should switch over to loading it globally like you do. I also went ahead and removed the ugly psr-0 line and added the path to the classmap. I hope there aren't any drawbacks to this.

"classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php", "app/Acme"

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

dlmcglone dlmcglone Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.