<p>You could put that code in index.php, before the <code>require_once</code> line. That’s about as early in the request as you can get ;)</p>

CC BY-SA 3.0
2015-10-09T23:37:10.133Z
2015-10-09T23:37:10.133Z
Brandon Kelly
<p>I'm looking for a way to execute some code before the whole system loads, more precisely right before plugins are loaded/executed.</p>

<hr>

<p><strong>Use case</strong></p>

<p>I want to instanciate a custom object, that I need to interact with in my plugin, but I cannot declare it INSIDE my plugin. This object should actually be available in all plugins if needed.</p>

<p>Where should I put such code so it is reusable ?
Thanks a lot !</p>

<plugin-development>
Execute code before plugins are executed
# Execute code before plugins are executed

(Asked by: username_0 on 2015-10-09)

I'm looking for a way to execute some code before the whole system loads, more precisely right before plugins are loaded/executed.

---

**Use case**

I want to instanciate a custom object, that I need to interact with in my plugin, but I cannot declare it INSIDE my plugin. This object should actually be available in all plugins if needed.

Where should I put such code so it is reusable ?
Thanks a lot !

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2015-10-09. Score: 1

You could put that code in index.php, before the `require_once` line. That’s about as early in the request as you can get ;)


---

