Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Help me on Assets manager : “/index.php” is always prepended in the assets path when ouput

I'm new to phalcon framework but it seems great!

Thanks for devleoping this great framework!!

Recently I decided to use assets manager in my project but an issue occurred. when I try to output the added assets, it prints the path with '/index.php' prepended...

I put this code into controller's indexAction:

> $this->assets > > ->collection("commonJs") >
> ->addJs('js/draggable.js') >
> ->addJs('js/common.js') >
> ->addFilter( new Phalcon\Assets\Filters\Jsmin() ); > > $this->assets > > ->collection('commonCss') > > ->addCss('css/material-icons.css',true,false) >
> ->addcss('css/common.css',true,true) >
> ->addFilter(new Phalcon\Assets\Filters\Cssmin());

and use this inside volt to ouput the assets:

> <head> > > .... > > {{ assets.outputJs('commonJs')}} > > </head> > > <body> > > ... > > {{ assets.outputJs('commoCss')}} > > </body> >

but the printed output seems a little wierd:

I think it should prints the path like

> <link rel="stylesheet" type='text/css' href='css/common.css'>

or

> <script type='text/javascript' src='js/common.js'>

but it actually outputs like this:

> <link rel="stylesheet" type='text/css' href='/index.phpcss/common.css'> > > .. > > <script type='text/javascript' src='/index.phpjs/common.js'> >

or if i set the path in the addJs like '/js/...' instead of 'js/...' then output is :

> <script type='text/javascript' src='/index.php/js/...'>

I'm new to phalcon and I don't know what I'm doing wrong and how to remove prepended index.php in the output path.

Could someone please help me on this?

FYI, I'm using nginx with php7.1 & fpm and my nginx-site.conf is like below, which is almost same as phalcon documentation : > > server { > > listen 80; > > root /var/www2/public; > > index index.html index.htm index.php; > > # Make site accessible from http://localhost/ > > servername tpnew.dev; > > errorlog /usr/local/var/log/nginx/newtp.error.log; #debug; > > lognotfound off; > > > location / { > > tryfiles $uri $uri/ /index.php?url=$uri&$args; > > } > > location ~ .php$ { > > tryfiles $uri = 404; > fastcgipass 127.0.0.1:9000; # php71 > fastcgiindex /index.php; > fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscriptname; > include fastcgiparams; > fastcgisplitpathinfo ^(.+.php)(/.+)$; > fastcgiparam PATHINFO $fastcgipathinfo; > fastcgiparam PATHTRANSLATED $documentroot$fastcgipathinfo; > fastcgiparam SERVERNAME $servername; > > } > > location ~ /.ht { > > deny all; > > } > > } >



112.1k
Accepted
answer

Hmmmm maybe you have in baseUri index.php?



149

@Wojciech Ślawski,

omg, you are right!! you saved my day! I created a project using phalcon devtool, and it creates config file with baseUri defined...

after I comment out the baseUri, it works now...

thank you Wojciech! ...=)



4.8k

You can accept his answer.



149

@Videles , sorry didn't know that. I'll accept his answer