Trying to add forms


This is my second question here and understand that I am a beginner in phalcon. I am trying to add a form on my application within the following folder : /app/forms/SubmitSubtitlesForm.php

Here is what I did so far :

In my controller :

use Subtitles\Forms\SubmitSubtitlesForm;

public function submitAction()
   $submitForm = new SubmitSubtitlesForm(null);

Also added forms dir in my config.php

'formsDir'       => APP_PATH . '/app/forms/',

and my form file :


use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Password;
use Phalcon\Forms\Element\Submit;
use Phalcon\Forms\Element\Check;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\Identical;

class SubmitSubtitlesForm extends Form

    public function initialize()


Unfortunately I am getting the following error :

Fatal error: Class 'Subtitles\Forms\SubmitSubtitlesForm' not found in C:...\subtitles\app\controllers\SubtitlesController.php on line 37

Will appreciate some help.


edited Dec '15

Subtitles is a bit of a string strange name to begin your namespace with. Is that the name of your project? Could you post your loader setup?


Yes it is the name of my project, so far I have :

project name : subtitles controller : SubtitlesController.php

Loader setup is :


$loader = new \Phalcon\Loader();

 * We're a registering a set of directories taken from the configuration file

Thanks for your help!


Your form file doesn't have a namespace on it and so your controller is looking for Subtitles\Forms\SubmitSubtitlesForm and then although Phalcon is checking the registered form directory and possibly even loading that file then PHP is not finding that class.

Also, I think that you should register namespaces with the loader instead of directories.