gracious/doctrine-timestamp
gracious/doctrine-timestamp provides automatic timestamp management for Doctrine entities in Laravel. It sets created_at and updated_at values on insert and update, reducing boilerplate and keeping audit fields consistent across your application.
This is a major release (2.0.0) with two meaningful changes: the package now requires PHP 8+, and its primary API changed from a class to a trait. That second change is breaking: existing code that instantiated, extended, or type-hinted the old class will no longer work as-is.
Start here:
UPGRADE.md / CHANGELOG.md for the exact old class name and new trait name.php -v, composer.json require.php, CI matrix).grep -R "Vendor\\Package\\OldClass" app/ config/ tests/
use Vendor\Package\OldClass;
class MyService extends OldClass
{
}
the new usage will look like this:
use Vendor\Package\NewTrait;
class MyService
{
use NewTrait;
}
First practical use case: add the trait to the class where you previously used the package class, then run that class's existing tests. This validates method availability before you refactor the rest of the integration.
Compose the trait into your own class. The 2.0 API expects you to own the class and pull package behaviour in:
namespace App\Services;
use Vendor\Package\PackageTrait;
class ReportGenerator
{
use PackageTrait;
public function generate(): array
{
return $this->packageMethod();
}
}
Use trait aliasing when method names collide. This is common when moving from a base class to a trait:
use Vendor\Package\PackageTrait {
packageMethod as protected packageMethodAliased;
}
Prefer dependency injection at the boundary. If the trait exposes behaviour used across the app, wrap it in a small application service rather than sprinkling use PackageTrait through controllers, models, and jobs:
class ShippingCalculator
{
use PackageTrait;
public function quote(Order $order): Money
{
return $this->calculate($order);
}
}
Then inject ShippingCalculator wherever needed. This keeps the package boundary in one place and makes future major upgrades cheaper.
Refactor old inheritance and instantiation. If 1.x code did new OldClass(...) or extends OldClass, move construction concerns into your own class constructor and call trait methods from there. If it did app(OldClass::class), replace that with your own service binding:
// app/Providers/AppServiceProvider.php
$this->app->singleton(ShippingCalculator::class);
Update tests to reflect the new shape. Tests that mocked or instantiated the old class should now instantiate the class using the trait, or mock your wrapper service. If the trait has dependencies, set them through your class constructor.
Run PHP 8 compatibility checks across the integration. The package requires PHP 8, so your app must too. Check composer.json, Docker images, and CI. Also confirm your Laravel version supports PHP 8 (Laravel 9+ requires PHP 8.0; Laravel 8 supports it on recent patch releases).
composer update.OldClass $dependency type hints must be replaced with your own class or interface.self:: behaviour can shift. Traits are flattened into the using class, so self:: and static:: resolve to your class. Verify anything relying on late static binding.composer.json allows your Laravel version alongside PHP 8; a PHP bump alone does not guarantee framework compatibility.use Vendor\Package\PackageTrait; inside the class body) and not just imported as a namespace at the top of the file. These two use statements are easy to confuse during the migration.How can I help you explore Laravel packages today?