Reputation: 674
I am trying to include the YouTube Analytics Service of Google but I can not access it through the Vendor folder.
include(app_path.'path/to/analytics/Google_YoutubeAnalyticsService.php')
It is not working, because it defaults to the App folder.
How can I get out of the App folder and into the Vendor folder (where the YouTube Analytics file is at)?
The error is {
include(C:\xampp\htdocs\mysite\app/path/to/analytics/Google_YoutubeAnalyticsService.php): failed to open stream: No such file or directory
Upvotes: 14
Views: 46884
Reputation: 1144
Actually you have in the helpers function the path so basically the function base_path give the direction to the root of your project so
echo base_path('vendor');
Should be the route to your vendor folder.
You can se all the documentation in Helper Functions Laravel
Be sure that you are seeing the documentation of the laravel version that you are using (I put the link for the 4.2 version).
Upvotes: 11
Reputation: 3059
This question was asked a long time ago and the answers reflect that. Most the time now all you need to do is import it using the "use" statement if you installed it with composer. Composer will already reference all the important directories.
It should be something like this, but it will vary depending on the project.
use FolderNameUsuallyGitHubUserName\ClassNameorGitHubProjectName\Class;
That could include a base class as well as some exception classes.
use FolderNameUsuallyGitHubUserName\ClassNameorGitHubProjectName\ClassException;
Usually most packages if compliant with modern composer and php standards work in this fashion.
Upvotes: 2
Reputation: 3451
From where do you want to include that file ?
Place a reference to your file in composer.json autoload object:
"autoload": {
"files":["your_file_path"]
}
Run composer dumpautoload, and you'll have your file :)
Upvotes: 17