artiframe optimize
The artiframe optimize command is one of the most critical building blocks of ArtiFrame's "Zero Overhead" philosophy. Instead of parsing a file on every HTTP request to read your project's environment variables (.env), it compiles this data into a highly performant static PHP cache file.
Usage
$ artiframe optimize
How It Works
When you execute this command, the following operations occur:
- The system reads the
.envfile in the project's root directory. - It parses the variables, ignores comments (
#), and casts values to their appropriate data types (string, boolean, etc.). - It converts the resulting array into pure, native PHP code and saves it at
config/env-cache.php.
$ artiframe optimize
✅ Environment variables cached successfully at config/env-cache.php
⚠️ IMPORTANT: Add env-cache.php to your .gitignore if running locally.
Performance Impact (Why Should I Use It?)
Forcing PHP to hit the disk, read the .env file, parse it with Regex, and assign variables on every single request incurs CPU and I/O costs, even if measured in microseconds. With ArtiFrame's caching mechanism, your application's bootstrap time is nearly cut in half.
It is highly recommended to run this command after every deployment, especially on Production servers.
Security Warning: The generated
config/env-cache.php file contains critical information such as database passwords. If you are working in a local environment, ensure this file is added to your .gitignore so it doesn't leak into version control systems like GitHub.