# Extension Cleanup

- Thread: https://externals.io/message/14911
- Original archive: https://news-web.php.net/php.internals/14911
- Started by Chris Cranford on 2005-02-14T03:33:28+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14911 — Chris Cranford — 2005-02-14T03:33:28+00:00

URL: https://externals.io/message/14911#14911

Is there a set of functions within an extension that is called automatically
by the ZEND engine framework to "initialize" and "deinitailize" the
extension?

In a particular PHP script, a user may call a method that sets up an
environment.  I cannot always rely on the user to call the cleanup API
method at the end of the script.  In that event, I would like my extension
to automatically cleanup after itself when the script completes.

Is there anyway to do this?

---

## #14912 — Sara Golemon — 2005-02-14T03:38:00+00:00

URL: https://externals.io/message/14911#14912 · In reply to: #14911

> Is there a set of functions within an extension that is called 
> automatically
> by the ZEND engine framework to "initialize" and "deinitailize" the
> extension?
>
MINIT: Module Initialization (Called once when the PHP processor is started)
RINIT: Request Initialization (Called at the start of every request)
RSHUTDOWN: Request Shutdown (Called at the end of every request)
MSHUTDOWN: Module Shutdown (Called when the PHP processor exits)


> In a particular PHP script, a user may call a method that sets up an
> environment.  I cannot always rely on the user to call the cleanup API
> method at the end of the script.  In that event, I would like my extension
> to automatically cleanup after itself when the script completes.
>
Resource dtors are also good for that kinda thing.

-Sara
