Milkadmin Local Directory
The milkadmin_local directory is the customization layer for your MilkAdmin installation. It allows you to override core functionality, add custom modules, and manage installation-specific settings.
Overview
The milkadmin_local directory serves as the customization and configuration layer that defines what makes each installation unique. It handles:
- Language files and translations
- Media files and uploads
- Storage (including SQLite databases)
- Configuration files
- Custom code and overrides
milkadmin framework, making it easy to update the system without losing your customizations.
Overriding Core Files
You can override virtually any file from the core framework by replicating its folder structure inside milkadmin_local. This includes:
- Views (templates)
- Email templates
- Assets (CSS, JS, images)
- PHP files from modules
- Theme files
How It Works
Simply maintain the same folder structure in milkadmin_local as exists in milkadmin. When the system loads a file, it checks milkadmin_local first, then falls back to the core milkadmin directory.
Example: Overriding a Module View
Core file:
milkadmin/Modules/Posts/Views/list.php
Override file:
milkadmin_local/Modules/Posts/Views/list.php
Overriding PHP Files and Namespaces
When overriding PHP files from modules, you must update the namespace by adding Local\ as a prefix.
Example: Overriding a Controller
Core module controller:
// milkadmin/Modules/Posts/PostsController.php
namespace Modules\Posts;
class PostsController {
// ...
}
Override in local:
// milkadmin_local/Modules/Posts/PostsController.php
namespace Local\Modules\Posts;
class PostsController {
// Your customized version
}
Local\ namespace prefix is required for all PHP overrides. Without it, the autoloader won't find your custom classes.
Custom Modules
You can create installation-specific modules inside milkadmin_local to keep them separate from the core system. This is useful for:
- Site-specific functionality
- Custom integrations
- Experimental features
- Client-specific requirements
Creating a Custom Module
milkadmin_local/Modules/CustomFeature/
├── CustomFeatureController.php
├── Views/
│ └── index.php
└── plugin.php
// milkadmin_local/Modules/CustomFeature/CustomFeatureController.php
namespace Local\Modules\CustomFeature;
class CustomFeatureController {
// Your custom module logic
}
Remember to use the Local\ namespace prefix for all custom modules as well.
Functions.php - Custom Code
The milkadmin_local/functions.php file is loaded at system startup, similar to WordPress's functions.php. Use it to add custom code without modifying core files.
Example Usage
// milkadmin_local/functions.php
// Add custom utility functions
function my_custom_helper($data) {
return strtoupper($data);
}
// Register custom hooks
add_action('after_login', function() {
// Custom logic after user login
});
// Modify system behavior
add_filter('post_content', function($content) {
return $content . ' - Custom Footer';
});
functions.php for small customizations and utilities. For larger features, create a proper custom module instead.
Directory Structure
Typical milkadmin_local structure:
milkadmin_local/
├── config.php # Installation-specific configuration
├── functions.php # Custom code loaded at startup
├── Languages/ # Translation files
├── Media/ # Uploaded images and files
├── storage/ # SQLite databases and storage
│ └── milk_conf_*.db # Configuration database
├── Modules/ # Override or custom modules
│ └── Posts/
│ └── PostsController.php
└── Theme/ # Theme overrides
└── Plugins/
└── CustomPlugin/
Configuration Files
The config.php file in milkadmin_local contains installation-specific settings like database credentials, site URL, and custom constants.
Available Configuration Parameters
Beyond the standard database and environment settings, you can define additional configuration parameters in milkadmin_local/config.php:
| Parameter | Description | Example |
|---|---|---|
$conf['page_info_limit'] |
Default number of rows per page for all tables created with TableBuilder | $conf['page_info_limit'] = 50; |
Example Configuration
// milkadmin_local/config.php
// Database settings
$conf['db_type'] = 'sqlite';
$conf['db_host'] = '';
$conf['db_name'] = 'storage/milk_conf_01b0eb8b68.db';
// Table defaults
$conf['page_info_limit'] = 50; // Default rows per page for TableBuilder
// Other custom settings
$conf['site_name'] = 'My Custom Site';
$conf['timezone'] = 'Europe/Rome';
$conf array.
Storage Directory
The storage/ folder inside milkadmin_local contains:
- SQLite database files (when using SQLite)
- Cached data
- Temporary files
- Session data
milkadmin_local directory is placed outside the web root, as it contains sensitive configuration and database files.
Best Practices
1. Version Control
Add milkadmin_local to your version control system to track customizations separately from core framework updates.
2. Namespace Consistency
Always use Local\ prefix for namespaces in PHP files within milkadmin_local.
3. Override Sparingly
Only override files when necessary. Excessive overrides can make system updates more complex.
4. Document Customizations
Keep notes about what you've customized and why, especially for complex overrides.
See Also
- Server Deployment - Learn about proper folder structure and security
- Creating Modules - Module development basics