Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Api Platform Traits

Api Platform Traits Laravel Package

l0wskilled/api-platform-traits

API Platform Traits offers reusable ORM and ODM traits for identifiers, timestamps, and soft deletes, with setup guidance for Gedmo/Stof Doctrine extensions to simplify common entity properties in API Platform projects.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Api Platform Traits
Is l0wskilled/api-platform-traits compatible with Laravel?
No. The package is a Symfony bundle (Epubli\ApiPlatform\TraitBundle) built on Doctrine ORM/ODM and the Gedmo extensions, with no Eloquent, Artisan, or Laravel service-provider integration. Laravel already provides timestamps, soft deletes, and UUID/ID traits natively. If your app is Laravel, close the evaluation and do not add this dependency.
How do I install l0wskilled/api-platform-traits in a Symfony API Platform project?
Run composer require l0wskilled/api-platform-traits, register Epubli\ApiPlatform\TraitBundle, and add the stof_doctrine_extensions YAML block shown in the README with softdeleteable and timestampable enabled. Then use the ORM or ODM traits inside your entities and add the Gedmo class-level annotations such as @Gedmo\SoftDeleteable. The package itself is a thin convention layer; the actual behavior comes from Gedmo listeners and Doctrine filters.
What do the six traits in api-platform-traits actually provide?
They provide three ORM traits and three ODM traits covering an identifier, timestampable fields, and soft-deletable fields. Each trait contributes properties and mapping hints only, not runtime behavior. The real timestamp and soft-delete logic is handled by Gedmo listeners and the Doctrine soft-delete filter.
Do I need stof/doctrine-extensions-bundle and Gedmo for these traits to work?
Yes. The traits are inert without the Gedmo extension suite wired through stof/doctrine-extensions-bundle. You must enable softdeleteable and timestampable in the stof_doctrine_extensions config and annotate entities with the relevant Gedmo mappings. The README's YAML snippet and @Gedmo\SoftDeleteable example are required setup, not optional extras.
Does api-platform-traits support API Platform 3, Doctrine ORM 3, and PHP 8 attributes?
There is no evidence of support. The package's last release was 2020-04-21, and its traits and README are annotation-based, while Doctrine ORM 3, DBAL 4, and API Platform 3 moved to PHP attributes and deprecated or removed annotation support. On a modern PHP 8.2+ baseline you should expect to fork and rewrite annotations as attributes, and you must check the composer.json constraints on the default branch rather than the README.
How do I configure soft deletes and timestamps with api-platform-traits?
Enable softdeleteable and timestampable under the orm.default key in config/packages/stof_doctrine_extensions.yaml. Then add the OrmTimestampableTrait and OrmSoftDeletableTrait to your entity and place the class-level @Gedmo\SoftDeleteable annotation with the correct fieldName. You also need to enable the SoftDeleteable Doctrine filter so queries exclude soft-deleted rows.
How do I hide deletedAt and soft-deleted records from API Platform responses?
The traits only add the property and mapping; serialization is controlled by API Platform serialization groups and the SoftDeleteable Doctrine filter. Enable the filter so soft-deleted rows are excluded from queries, and use groups or ignored attributes so deletedAt is not exposed to consumers. Decide explicitly whether deleted records should be visible to admins and document that policy.
Is l0wskilled/api-platform-traits safe to use in production?
Treat it as high lifecycle risk. It is a single-maintainer, effectively dormant package with a 2020 release, 1 star, 0 dependents, no CI or static analysis visible, and no version-compatibility matrix. The code surface is tiny (about six small traits), so the safer production path is to vendor or reimplement the traits under your own ownership.
Should I composer require api-platform-traits or copy the traits into my application?
The strong default is to vendor the traits into your app or an internal bundle. Depending on the package inherits staleness, annotation-era constraints, and a bus factor of one, while copying costs hours because the code is only about six small traits. Owning the code lets you rewrite annotations as PHP attributes and control the soft-delete data-exposure policy.
What are the Laravel alternatives to api-platform-traits for IDs, timestamps, and soft deletes?
Laravel's Eloquent already provides timestamps and SoftDeletes, and you can add UUID or ULID identifiers with the HasUuids or HasUlids traits. If you use Doctrine inside Laravel, you would wire Gedmo or a similar Doctrine extension yourself rather than relying on this Symfony bundle. This package offers nothing for Eloquent and should not be evaluated as a Laravel dependency.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections