PHP code example of globus-studio / atomic-framework
1. Go to this page and download the library: Download globus-studio/atomic-framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Engine\Atomic\Core\Middleware\MiddlewareInterface;
class Authenticate implements MiddlewareInterface
{
public function handle(\Base $atomic): bool
{
// Return true to continue, false to abort
return Guard::is_authenticated();
}
}
use Engine\Atomic\App\Plugin;
final class ExamplePlugin extends Plugin
{
protected function get_name(): string
{
return 'ExamplePlugin';
}
public function ],
],
];
}
}
use Engine\Atomic\App\Controller;
class DashboardController extends Controller
{
public function index(\Base $f3): void
{
// Middleware is enforced automatically
$this->render('dashboard/index.html');
}
}
use Engine\Atomic\App\Model;
class User extends Model
{
protected function get_rules(): array
{
return [
'email' => ['rule' => Rule::EMAIL, '
}
use Engine\Atomic\Event\Event;
Event::instance()->on('user.created', function ($data) {
// Send welcome email
}, priority: 10);
Event::instance()->emit('user.created', ['user' => $user]);
use Engine\Atomic\Hook\Hook;
Hook::instance()->add_action('after_login', function ($user) {
// Track login
});
$title = Hook::instance()->apply_filters('page_title', $rawTitle);
use Engine\Atomic\Tools\Transient;
use Engine\Atomic\Core\CacheManager;
// Store a value with TTL
Transient::set('stats', $data, 3600);
$cached = Transient::get('stats');
// Cache cascade: honors CACHE_CONFIG and falls back through Redis → Memcached → Folder
$cache = CacheManager::instance()->cascade();
$cache->set('stats', $data, 3600);
$cache->clear('stats');
// Long-running workers can refresh the cached generation after an external reset.
$cache->flush_local_cache();
// Transients use WordPress-like priority:
// Redis → Memcached → DB → Folder