Skip to main content
9 votes

Bootstrap from external script

For current version of drupal 8.x: define('DRUPAL_DIR', '/usr/share/nginx/html'); use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; require_once DRUPAL_DIR . '/core/includes/...
Sergey's user avatar
  • 91
5 votes
Accepted

What does the term 'Bootstrap' mean?

In computing, "bootstrapping" refers to software getting to a state to where it can perform the task being requested. In the context of Drupal, it means the code starts and does everything up to the ...
mpdonadio's user avatar
  • 38.1k
4 votes
Accepted

Why does DRUPAL_BOOTSTRAP_PAGE_CACHE phase come before DRUPAL_BOOTSTRAP_DATABASE?

Inside of _drupal_bootstrap_page_cache() the key bit of information is this bit of code if (variable_get('page_cache_without_database')) { $cache_enabled = TRUE; } else { ...
mikeytown2's user avatar
  • 8,322
3 votes
Accepted

How can I bootstrap my site from an external script?

Here is the code that allows entity creation in a D9 site from a remote script - run from the same domain as the D9 site but not from the D9 root directory. <?php //drupal root directory chdir('/...
peter300's user avatar
3 votes
Accepted

Cannot get currentUser after custom Drupal boot

You have to authenticate the user. This is what a normal Drupal request would do as one of the first things after the kernel is booted: Drupal\Core\EventSubscriber\AuthenticationSubscriber public ...
4uk4's user avatar
  • 100k
3 votes
Accepted

How do I check the current user session?

You can't really do something like that in Drupal 8. The short story is that we use Symphony for the Request / Response flow, so actually bootsrapping Drupal is a lot more complex than simply ...
googletorp's user avatar
  • 35.4k
3 votes

Bootstrap from external script

You can use the following to bootstrap Drupal 8 from an external script to query the database: use Drupal\Core\DrupalKernel; use Drupal\Core\Site\Settings; use Symfony\Component\HttpFoundation\Request;...
Soufiane Sakhi's user avatar
2 votes

Bootstrap from external script

To bootstrap Drupal 8 from an external script, I would use the following code, similar to the code used in the authorize.php file. use Drupal\Core\DrupalKernel; use Symfony\Component\HttpKernel\...
apaderno's user avatar
  • 97.5k
2 votes
Accepted

How to affect kernel request hostname when bootstrapping from custom PHP script

You need to use the HTTP_HOST instead the SERVER_NAME, also you can pass it as $server param to the Request::create() $autoloader = require_once 'web/autoload.php'; $request = Request::create('/', '...
quex's user avatar
  • 677
1 vote

Programmatically log in a user

The code shown in the question would throw an error about user_login_finalize() not being defined. The code isn't loading the User module and the DrupalKernel class doesn't load any module. I ...
apaderno's user avatar
  • 97.5k
1 vote
Accepted

How to bootstrap a custom script and retrieve the session object?

This is the code I came up with in the end. It works. Feel free to suggest a more concise version :-) <?php use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; $...
Koala Yeung's user avatar
1 vote
Accepted

Script exits on drupal_bootstrap_full when run from system cron

I found the issue is i have multiple PHP versions installed on my system because my hosting company is running plesk. PHP 5.2 is a base version and it looks like drupal loads something that makes php5....
Lindsay Mickey's user avatar
1 vote
Accepted

How can I bootstrap?

I ended up inheriting the kernel and will adjust it as needed be. Something like: namespace Drupal\Core; use Drupal\Core\Site\Settings; class DrupalCliKernel extends DrupalKernel { public ...
johndevman's user avatar
1 vote
Accepted

Drupal 8 - what is application bootstrapper or auto-loader

Yep this is because of composer ... you will see one if you install anything using composer. here is an example of an autoloader that is automatically created by Composer. ?php /** * @file * ...
taggartJ's user avatar
  • 2,190
1 vote
Accepted

How can I bootstrap a multi-site instance?

I was able to get this working by setting the server variable $_SERVER['SCRIPT_NAME'] to '/subsite/index.php' (where /subsite/ is the url path to the subsite). $_SERVER['SCRIPT_NAME'] = '/subsite/...
Ch4mb3rs's user avatar
1 vote

What is the basic concept behind hooks?

Hooks. Allow modules to interact with the Drupal core. Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the ...
Amrendra Mourya's user avatar
1 vote

What is the basic concept behind hooks?

To me it's all about the module_implements function when it comes to hooks and core (D7). One thing that I think is crucial to understand is that by writing a hook to modify something, you by no ...
Dan Shumaker's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible