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

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 https://localhost/

server_name tpnew.dev;

error_log /usr/local/var/log/nginx/newtp.error.log; #debug;

log_not_found off;

location / {

   try_files $uri $uri/ /index.php?_url=$uri&$args;

}

location ~ .php$ {

   try_files      $uri = 404;
   fastcgi_pass   127.0.0.1:9000; # php71
   fastcgi_index  /index.php;
   fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include        fastcgi_params;
   fastcgi_split_path_info  ^(.+\.php)(/.+)$;
   fastcgi_param PATH_INFO       $fastcgi_path_info;
   fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
   fastcgi_param SERVER_NAME $server_name;

}

location ~ /.ht {

   deny all;

}

}



145.0k
Accepted
answer

Hmmmm maybe you have in baseUri index.php?



757

@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! ...=)



13.8k

You can accept his answer.



757

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