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

PhalconException: JsController handler class cannot be loaded

im including my javascript file thru this:

<script src="js/vendors/jquery-1.10.1.min.js"></script> or {{ javascript_include("js/vendors/jquery-1.10.1.min.js") }}

but im getting this error (PhalconException: JsController handler class cannot be loaded) whenever i click the link.



98.9k

It means the file does not exist at:

public/
 js/
  vendors/
   jquery-1.10.1.min.js

it exist. but when i try to move the jquery file one directory down to js folder it work! but under the js/vendors folder it doesnt.

[UPDATE] i configured my app url to https://myapp.dev but when i access my app thru this url (https://localhost/myapp/) the jquery file under the js/vendors folder works! weird! i think this has effect on the .htaccess file?



98.9k

You have to adjust your baseUri according to the host:

$di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/'); // https://myapp.dev
        $url->setBaseUri('/myapp/'); // https://localhost/myapp/
        return $url;
});
edited Mar '14

im using this setting

$di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/'); 
        return $url;
});

to access my app https://myapp.dev, but i tried to change it like this

$di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/myapp/'); 
        return $url;
});

and access at the same url (https://myapp.dev) the jquery file under the js/vendors folder works fine as well as https://localhost/myapp/