laravel 4视图,在哪里放置基于类的作曲家

I found that I can create a callback function using view composer

http://laravel.com/docs/responses#view-composers

so how to use class based composer:

View::composer('profile', 'ProfileComposer');

where to place ProfileComposer class?

thanks,

You can have that ProfileComposer class inside ProfileComposer.php file and that will be in anywhere you want, if that file is autoloaded. You should be watching a video tutorial about Composers in Laracasts, and it will explain you why we have to use View::composer and how we can use.

The view composer class should be defined as any regular class and might be stored in a libraries folder or if it is only used by a model you might store it there, there is no convention of where to store it. The class can hold some processes you want to reuse and you can register the call in a serviceprovider. This is a great tutorial on how to use it.

http://culttt.com/2014/02/10/using-view-composers-laravel-4/

I just find the answer in official decumentation.

you can put composer files anywhere in application file system, ex app/composer

and add it to composer.json

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/filters",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php",
        "app/composer"
    ]
},

then run artisan autoload:

php artisan dump-autoload

thanks everybody,