# Config/bootstrap

**URL:** <https://discourse.cakephp.org/t/config-bootstrap/10037>\
**Category:** Need Help\
**Created:** [December 29, 2021, 11:11am UTC](https://discourse.cakephp.org/t/config-bootstrap/10037 "2021-12-29T11:11:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [December 29, 2021, 11:11am UTC](https://discourse.cakephp.org/t/config-bootstrap/10037/1 "2021-12-29T11:11:40Z")

</div>

cakephp 4.x

In v2.x and 3.x I loaded variables from plugin-\>config-\>bootstrap.

I am updating a plugin to 4.x and try to do the same but it does not seem to work the same way.

In src/application :

```auto
$this->addPlugin('Medias', ['bootstrap' => true, 'routes' => true]);

```

In plugin/media/config/bootstrap :

```auto
use Cake\Core\Configure;

Configure::write('image_types', ['image/png', 'image/jpeg', 'image/gif']);

```

And in a view file :

```auto

use Cake\Core\Configure;

$image_types = Configure::read('image_types');

debug($image_types) => null

```

So what’s wrong ?

---

<div class="post-metadata">

**Author:** ![brent](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@brent](https://discourse.cakephp.org/u/brent)\
**Post date:** [December 29, 2021, 2:24pm UTC](https://discourse.cakephp.org/t/config-bootstrap/10037/2 "2021-12-29T14:24:06Z")

</div>

In your Medias Plugin class, do you have a bootstrap method? My initial guess is that you have to call parent.

```php
class Plugin extends BasePlugin
{
    /**
     * Load all the plugin configuration and bootstrap logic.
     *
     * The host application is provided as an argument. This allows you to load
     * additional plugin dependencies, or attach events.
     *
     * @param \Cake\Core\PluginApplicationInterface $app The host application
     * @return void
     */
    public function bootstrap(PluginApplicationInterface $app): void
    {
        parent::bootstrap($app); // call parent
        
        Configure::write('image_types', ['image/png', 'image/jpeg', 'image/gif']);
    }
....

```

Since moving/upgrading to CakePHP v4.x I have avoided the `bootstrap.php` & `routes.php` files and handled everything via the Plugin class and loaded specific configuration files.

---

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [December 29, 2021, 3:27pm UTC](https://discourse.cakephp.org/t/config-bootstrap/10037/3 "2021-12-29T15:27:48Z")

</div>

That’s it !

```auto
public function bootstrap(PluginApplicationInterface $app): void
    {
        parent::bootstrap($app); // call parent
    }

```

and my plugin/media/config/bootstrap.php file is left unchanged width various variables.

Thank you.
