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/...
8
votes
Accepted
Site performance , cache not working properly
Slide #85 from my performance presentation talks about max packet size in MySQL, you need to increase that value; SET GLOBAL max_allowed_packet=33554432; or change it inside of the configuration file ...
5
votes
Bootstrap from external script
I finally ended up with this code. It has some ugly extra includes but at least it works:
define('DRUPAL_DIR', __DIR__ .'/../drupal');
use Drupal\Core\DrupalKernel;
use Symfony\Component\...
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 ...
4
votes
Drush command needs higher bootstrap level - Pantheon Drush Alias Setup
While sites on Pantheon don't require a settings.php file in order to serve web requests, due to the fact that database credentials are dynamically injected, they will still need a settings.php ...
4
votes
Accepted
Where I can find examples of Drupal bootstrap levels?
The JS module is specifically for this. It allows you to create ajax callback that only bootstrap to a level you specify via a hook_js().
So you could either use this module or take a look at its ...
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 {
...
3
votes
Accepted
Drush command needs higher bootstrap level - Pantheon Drush Alias Setup
Ok so this is how i solved it after 4 days of trying... the docs and support techs on pantheon are not clear which has lead to this confusion and im sure many others too.
To get Drush aliases to work ...
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 ...
3
votes
Accepted
How to load aggregated styles / js in an 'external' script via DRUPAL_BOOTSTRAP_FULL?
Here's the gist of it (w/ commentary).
<?php
// ... your code
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// get current theme and it's variables
$current_theme = variable_get('theme_default','none'...
3
votes
Bootstrap from external script
Firstly: Always look for change notices. You can find them here: https://www.drupal.org/list-changes
Here's the main one dealing with drupal_bootstrap(): https://www.drupal.org/node/2275139
Have a ...
3
votes
Accepted
Error: Class 'Drupal' not found in bootstrap.inc
Drush 6.x only works with Drupal 6 or 7, upgrade to Drush 7.x.
Source
3
votes
Site performance , cache not working properly
It is just a hypothesis but if your bootstrap cache rebuilds on every page load it may happen that some of your modules missing in modules folder but still present in system table. On each page load ...
3
votes
Site performance , cache not working properly
Max allowed packet size could be one reason this is happening, but I can see multiple reason why it is probably something else in this case.
You don't just have cache writes, you also have explicit ...
3
votes
Properly bootstrap drupal for standalone PHP file?
this is enough:
set_include_path(get_include_path() . PATH_SEPARATOR .'/path/to/drupal/root/');
define('DRUPAL_ROOT', '/path/to/drupal/root/');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
...
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 ...
2
votes
When is it appropriate to run a drupal_bootstrap?
In order to bootstrap Drupal from another PHP script, you can use below code:
define('DRUPAL_ROOT', '/path/to/drupal');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(...
2
votes
Accepted
Adding custom classes to Views Filters (view-filters) and Content (div.view-contents)
Views provides a lot of .tpl files for doing just this. They are found in the /theme folder of the views module folder. The one you want is views-view.tpl.php
Simply copy views-view.tpl.php into your ...
2
votes
Accepted
Avoid drupal bootstrap for each image styles in private filesystem
Haven't tried this before, but you could write an image field formatter that converts the thumbnail files to inline data URIs, eliminating the separate HTTP requests per image. That adds some overhead ...
2
votes
Avoid drupal bootstrap for each image styles in private filesystem
No because it are separate http(s) requests. Every requests needs to redo the check.
2
votes
Change appearance of search form
To design the search block form you can override the existing search-block-form.tpl.php in the theme's template folder.
<?php
$variables['form']['search_block_form']['#attributes']['placeholder']...
2
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;...
2
votes
Drupal as a RestAPI
Most of the speed costs to Drupal (beyond php as a language) are from the render layer.
If using Drupal just as a RESTful api, having fewer modules enabled (i.e. Views plugins) will likely cut down ...
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('/', '...
2
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('/...
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....
1
vote
Accepted
Is it possible to have an external script run index.php that bootstraps Drupal?
To answer your question - Yes, it is possible to have an external script to bootstrap Drupal.
If Drupal is installed in the folder [root], and the index.php file that you want to get working is in [...
1
vote
Accepted
Drupal as a RestAPI
In drupal 7 you can use a contrib module called services, this will help you expose json by default for all nodes. You can also output main from hook_menu.
If you use laravel you may be more ...
1
vote
Bootstrap from external script
For bootstrapping 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\...
1
vote
Where I can find examples of Drupal bootstrap levels?
I think the best place to start answering your question its to look at Drupal's own boostrap implementation.
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_bootstrap/7
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
bootstrapping × 947 × 32
8 × 12
drush × 12
theming × 8
external-scripts × 8
caching × 6
views × 5
database × 5
hooks × 5
users × 4
sessions × 4
nodes × 3
entities × 2
updating × 2
installation × 2
performance × 2
multi-sites × 2
javascript × 1
files × 1
search × 1
i18n-l10n × 1
navigation × 1
panels × 1
redirection × 1