I need get full path to my web-project directory, as I am using single entry point so I doing this:
$_SERVER['SCRIPT_FILENAME']
then remove index.php
and then I get something like this: /var/www/myproject
, and then I can use it for require some stuff files like configuration etc. But when I call this method (e.g. for include some stylesheets) in my php files for rendering I getting 404 error for this stylesheet and what I getting in browser console:
http://localhost/var/www/myproject/bower_components/bootstrap/dist/css/bootstrap.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
Obviosly that path should looks like:
http://localhost/myproject/bower_components/bootstrap/dist/css/bootstrap.min.css
So the question is how I can properly get path to my project for proper include files in PHP and load assets in HTML ? And the approach what I am using now it ok? Or I need to do somehow better? Thanks!