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

How can I create a plugin and how can I call it

I need to create a facebook login plugin. I have alredy downloaded the SDK which I extracted and stored in a folder called facebook. Inside a plugin folder I created placed inside app folder. -App --Plugins ---facebook ----src files
Please advice. Thanks



7.9k

You may consider using strategy design pattern : https://sourcemaking.com/design_patterns/strategy

I have managed by creating a directory plugins and registering it with autoloader in order for my app to easily access its classes. After that I set its classes in the DI component through service.php



2.1k
edited Feb '15
$loader->registerNamespaces(
        array(
        "Facebook" => APPLICATION_PATH."/../library/Facebook",
                )
);

and..

https://gist.github.com/JREAM/8554151



31.2k
Accepted
answer

I Added the plugins directory holding the classes in the config file and then registered my plugin in the service file through the di component.

After that I am able to execute it as I need in the application controllers.