robclancy / presenter

Decorate your objects using presenters. Primarily to keep presentation logic out of your models.
MIT License
345 stars 38 forks source link

L4 resourceful controllers implementation? #4

Closed seblavoie closed 11 years ago

seblavoie commented 11 years ago

I tried installing it in a L4 app with resourceful controllers and followed documentation's steps.

  1. Required the package in my composer and added it to config/app.php providers.
  2. Created app/presenters folder.
  3. Created app/presenters/ProjectPresenters.php containing this code:

    <?php
    
    use Robbo\Presenter\Presenter;
    
    class ProjectPresenter extends Presenter
    {
    }
  4. Added

    class Project extends Eloquent implements PresentableInterface {
    ...
    function getPresenter()  
    { 
     return new ProjectPresenter($this);  
    }

    to my Project model.

  5. And here's what I have in my controller:

    public function index()
    {
     return View::make('site/projects/index')
       ->with('projects', Project::all());
    }

But I keep on getting Class 'ProjectPresenter' not found and with this code highlighted:

public function getPresenter()
{
  return new ProjectPresenter($this);
}

The docs seems to contain L3 code but as I understood L4 is supported. Am I missing something?

robclancy commented 11 years ago

You need to add the presenters folder to autoloading. Both in composer.json and start/global.php

seblavoie commented 11 years ago

Oh voilà! Thanks a lot, works like a charm now.