I am working on a Drupal 8 site. This site was working. I recently moved to another machine.
It is showing errors like:
Recoverable fatal error: Argument 1 passed to
Drupal\Component\DependencyInjection\Container::__construct() must be of
the type array, boolean given, called in [DRUPAL-
PATH]/core/lib/Drupal/Core/DrupalKernel.php on line 883 and defined in
[DRUPAL-PATH]/core/lib/Drupal/Component/DependencyInjection/Container.php
on line 119 #0 [DRUPAL-PATH]/core/includes/bootstrap.inc(550):
_drupal_error_handler_real(4096, 'Argument 1 pass...',
'/Applications/M...', 119, Array)
I need to clear cache programmatically.
To clear all caches, use the cache-rebuild command: drush cache-rebuild . This will empty all caches and rebuild the data required for Drupal to execute a page request. Alternatively, use the aliased commands drush cr or drush rebuild .
Primary tabs To clear cache in Drupal you have to navigate Configuration->Performance->Clear All Caches. But with this module, you can get a button on Admin Menu to clear cache and Save time.
Notes: In most computer-based web browsers, you can open menus used to clear cache, cookies, and history, by pressing Ctrl-Shift-Delete (Windows) or Command-Shift-Delete (Mac).
If you want to clear specific cache like render cache then you can run the following code:
\Drupal::service('cache.render')->invalidateAll()
If you want to clear all the cache then try:
drupal_flush_all_caches()
The following services implement the CacheBackendInterface
and has invalidateAll()
method which marks all the cache items as invalid:
cache.bootstrap
cache.config
cache.data
cache.default
cache.discovery
cache.entity
cache.menu
cache.render
cache.static
Try below.
cache_clear_all() // For Drupal-7
drupal_flush_all_caches() // For Drupal-8
By SQL
TRUNCATE `cache_bootstrap`;
TRUNCATE `cache_config`;
TRUNCATE `cache_container`;
TRUNCATE `cache_data`;
TRUNCATE `cache_default`;
TRUNCATE `cache_discovery`;
TRUNCATE `cache_dynamic_page_cache`;
TRUNCATE `cache_entity`;
TRUNCATE `cache_menu`;
TRUNCATE `cache_render`;
TRUNCATE `cache_rest`;
TRUNCATE `cachetags`;
TRUNCATE `cache_toolbar`;
By Drush
drush cr all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With