Reputation: 12945
I am using the Laravel 4 framework, and I am trying to set up the Facebook authentication system. I have an authentication system I had set up on another site (not using a framework) that used a config.php and process_facebook.php file. I am trying to implement this config.php file into my views. So far, I am including the files in a folder called "includes", within my "app" folder. I am trying to use the following code to implement it:
$app = app();
include($app['path.app'].'/includes/config.php');
My question is, where in the view do I put this code? Do I have to use php tags? (I am using the blad functionality). Your help is appreciated.
Upvotes: 0
Views: 162
Reputation: 6746
Laravel is an MVC framework, the purpose is to organise your code and clean your views. So this shouldn't be in your view.
I think the best way should be :
facebook.php
file in the config
folder wich contains all your facebook configuration (read http://laravel.com/docs/configuration)services
, helpers
or includes
(as you want) and put process_facebook.php
inside (I bet it contains the methods to deal with facebook API).Like that :
// composer.json
"autoload": {
"classmap": [
[...]
"app/services",
]
},
// start/global.php
ClassLoader::addDirectories(array(
[...]
app_path().'/services',
));
Then, you can use your facebook class or methods all over your app.
Upvotes: 2
Reputation: 9007
The route you are taking to include configuration files is not recommended, but it is possible. Please see information about Laravel Configuration Files.
You should be able to use the following in your view:
<?php include(app_path().'/includes/config.php'); ?>
As it is a configuration file, it would be better to use require()
instead of include()
.
In addition, it would also be better to include the file in the necessary controller(s).
Upvotes: 0