Skip to content

Instantly share code, notes, and snippets.

@cebe
Created October 16, 2013 11:55
Show Gist options
  • Save cebe/7006561 to your computer and use it in GitHub Desktop.
Save cebe/7006561 to your computer and use it in GitHub Desktop.
Autoloading namespaced model in yii 1.1
protected/controllers/EmailController.php
<?php
// no namespace needed here
class EmailController extends controller{
public function actionSend(){
$recipient = new \application\documents\email\Recipient();
}
}
protected/documents/email/Recipient.php
<?php
namespace application\documents\email;
class Recipient extends EMongoDocument{}
@cebe
Copy link
Author

cebe commented Oct 16, 2013

You can make action code look nicer by doing this in controller:

<?php

use application\documents\email\Recipient;

class EmailController extends controller{

    public function actionSend(){
        $recipient = new Recipient();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment