We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

models in plugins

Hi all

i have a model called "FacebookMeta" how can i use it on plugin?

<?php

use Phalcon\Events\Event,
Phalcon\Mvc\User\Plugin,
Phalcon\Mvc\Dispatcher,
Phalcon\Acl,
Phalcon\Mvc\Url,
Phalcon\Tag,
Phalcon\Mvc\View,
Phalcon\Mvc\Model;

class SetOgMeta extends Plugin
{

 public function setOgMeta()
{
    $uri = $this->router->getRewriteUri();

    $key = 'facebook_meta_'.md5($uri);

    if(!$this->ogMeta = $this->redis->get($key)){

    $fbMetas = FacebookMeta::findFirst(array("url = '".$uri."'"));          

    }

}

Fatal error: Class 'FacebookMeta' not found in /var/www/netmoda/app/plugins/SetOgMeta.php on line 134


8.1k
Accepted
answer

Add FacebookMeta to your use list?



39.2k

How i should do it ?

use Phalcon\Mvc\Model\FacebookMeta;



8.1k

How is your Loader set up?



39.2k

Thanks for all , i can setup without use parameters. Problem with my config , i made a mistake about models path.