v1.2.0
-
Built-in GraphQL server (
Naluz\GraphQL, no extra dependencies): parser, validator, executor, introspection and a PSR-7 endpoint (GraphQLController). Code-first schemas in PHP (ObjectType,InputObjectType,EnumType, custom scalars,Types::nonNull()/listOf()), resolvers with aResolveInfo(subfields()for eager loading), variables, fragments, aliases,@skip/@include, mutations. Secure by default: depth, size and token limits; input validated against the schema before any resolver runs; internal exceptions masked asInternal server error.(and reported to a logger); introspection off unless debugging; mutations refused over GET; batching refused. Configure withconfig/graphql.php(schema,max_depth,max_nodes,max_query_length,introspection). Not supported yet: subscriptions, interfaces / unions, SDL schemas, persisted queries. -
Model observers. Group a model’s event listeners in one class with
Model::observe(): every public method named after a model event (saving,saved,creating,created,updating,updated,deleting,deleted) is called with the model. Returningfalsefrom an-ingmethod cancels the operation.final class UserObserver{public function creating(User $user): void{$user->email = strtolower(trim($user->email));}}User::observe(UserObserver::class); // a class name, an object, or a list of them -
#[ObservedBy]attribute to declare observers on the model itself (inherited by child models):#[ObservedBy(UserObserver::class)]class User extends Model {} -
php naluz make:observer <Name>generator (createsapp/Observers/<Name>.php).
Behaviour notes
Section titled “Behaviour notes”- Observers given as class names are built lazily on the first event, through the container when one is available, so constructor dependencies are injected. One instance is reused per model class.
- Attaching the same observer twice is ignored; an unknown class throws
InvalidArgumentException. Model::flushEventListeners()also removes observers.- Observers fire on model instances only. Bulk query-builder writes (
->update()/->delete()on a query) do not fire model events, the same as closure listeners.
Upgrading
Section titled “Upgrading”Backwards compatible with 1.0.x: no existing API changed.
composer require naluz/framework:^1.2.2Samples and docs live in the application skeleton: https://github.com/taliffsss/naluzphp-framework
(app/Observers/, app/Providers/, docs/providers-and-observers.md).