Reputation: 789
I am currently developing php scripts, But At some point I wanted to connect to drupal database with my php scripts, I google about accessing drupal api with external php scripts, as many people suggested use bootstrap.inc file in your external php script, I like to ask here, lets say if I added this bootstrap.inc file and related code after that can i get access to use drupal api with its database?
I wanted to register a user with drupal database and also need to read some tables from drupal database, So can i achieved all this? including bootstrap.inc is enough or need to add any other module from drupal side, i external php script get access to drupal database?
Thanks.
Upvotes: 1
Views: 3240
Reputation: 2799
If you still want to work outside Drupal, in a standalone script, you should include Drupal's include/bootstrap.inc and call drupal_bootstrap()
function to initialize Drupal environment (connect to database, load modules, session, etc.). You can select the phase to bootstrap depending on what you need from Drupal.
define('DRUPAL_ROOT', 'YOUR DRUPAL ROOT');
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Drupal is fully loaded here, you can access everything.
information source: https://drupal.stackexchange.com/a/24117
drupal information: http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_bootstrap/7
Upvotes: 1