PHP Package: spatie/once

Spatie's Once PHP library ensures efficient, one-time execution in PHP applications, optimizing code performance and reducing redundant processing.

Current Version: 3.1.2
Last Updated: 2025-11-25
PHP Requirement: ^8.0
Dependencies:
phpunit/phpunit
php-fig/container
⚠️ To ensure full functionality, the above dependencies might be required.

Package Description

Spatie's Once PHP library empowers developers with a robust tool to execute code only once, enhancing application efficiency and performance. By preventing redundant processing, this library streamlines operations and boosts overall system performance, delivering optimal results.

📦 Show all available classes🔗 View on GitHub

Download Latest Version: 3.1.2

Download Download v3.1.2

Previous Versions

Code Integration Example

Make sure to include the correct namespace and class paths for proper usage.

<?php
// Example from PHPlibraries.com
require_once 'libs/spatie/once/3.1.2/loader.php';
require_once 'libs/sebastianbergmann/phpunit/12.4.4/loader.php';
require_once 'libs/php-fig/container/{lib_version}/loader.php';

use Spatie\Once\Once;

$obj = new Once();
echo '✅ Test OK: ' . get_class($obj);
?>

We aim to make using PHP packages easier without Composer. If something doesn't work, let us know — we'll fix it promptly.

Community Discussion

Ask questions, share tips, or report issues below.