Reputation: 3499
I'm having an issue with an include/require.
I made a dir in my root file:
root/includes
root/includes/something.inc.php
Now i try to include/require that file into my webapp:
require(Yii::app()->baseurl.'/includes/something.inc.php');
But it says failed to open stream: No such file or directory
When i go to mydomain/includes/something.php
it just works.
Why o why can't I include/require this file?
Upvotes: 0
Views: 862
Reputation: 2150
Yii(1) offers multiple shortcuts to various paths. The most commonly used one are available as Yii::app()->baseUrl
and Yii::app()->basePath
.
Both shortcuts serve different purposes and act on a different level. baseUrl
represents the url your application is available from on the web. And has it's use if you want to link assets and files by their public url. basePath
acts on the filesystem level. Includes are almost ever done on the filesystem-level. This mismatch is the cause of your problem.
Reference:
Upvotes: 2
Reputation: 90
You try to instead:
require(Yii::app()->baseurl.'/includes/something.inc.php');
by:
require(dirname(__FILE__).'/includes/something.inc.php');
Upvotes: 1