Skip to content

Add basic events and plugins functionality - #812

Merged
giuscris merged 25 commits into
2.xfrom
feature/events-and-plugins
Dec 7, 2025
Merged

Add basic events and plugins functionality#812
giuscris merged 25 commits into
2.xfrom
feature/events-and-plugins

Conversation

@giuscris

@giuscris giuscris commented Dec 6, 2025

Copy link
Copy Markdown
Member

This pull request introduces several significant changes to the Formwork CMS, focusing on extensibility, asset management, and event handling. The most impactful updates include a new event system for key application lifecycle moments, a refactored asset resolution mechanism with support for namespaced assets, and the addition of a plugin infrastructure. There are also configuration and service registration changes to support these new features.

Event System Enhancements:

  • Introduced new events for exception handling, response sending, and routing lifecycle (ExceptionThrownEvent, ResponseBeforeSendEvent, RoutesBeforeLoadEvent, RoutesAfterLoadEvent) and integrated them into the application flow. This allows plugins and other components to hook into these moments. [1] [2] [3] [4] [5] [6] [7] [8]

Asset Management Refactor:

  • Refactored the Assets service to support resolution paths for namespaced assets, allowing assets to be organized and referenced by namespace. Added a new AssetResolutionException for error handling. [1] [2] [3] [4] [5] [6]
  • Updated the application to register and provide the Assets service via dependency injection, and exposed it through the App class. [1] [2] [3]

Plugin Infrastructure:

  • Added a plugin system to the CMS, including configuration options to enable plugins and define their path, and registered the Plugins service in the application lifecycle. [1] [2] [3] [4] [5]

Configuration and Service Loader Updates:

  • Updated service loaders and dependency injection container definitions to support new and refactored services, including assets, plugins, events, and view resolution paths. [1] [2] [3] [4]

Tooling and Exclusion Patterns:

  • Updated project configuration files (.php-cs-fixer.php, .rector.php, phpstan.neon) to exclude the new site/plugins directory from code analysis and formatting tools. [1] [2] [3]

Other minor changes include the addition of the assets view method and a fix to use the correct namespaced template for error views. [1] [2] [3] [4] [5]

@giuscris giuscris added this to the 2.3.0 milestone Dec 6, 2025
@giuscris
giuscris requested a review from Copilot December 6, 2025 13:50
@giuscris giuscris self-assigned this Dec 6, 2025
@giuscris giuscris added the enhancement New feature or request label Dec 6, 2025
@giuscris
giuscris force-pushed the feature/events-and-plugins branch from 7abf8e7 to 97d81f5 Compare December 6, 2025 14:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a comprehensive event system, plugin infrastructure, and refactored asset/view management to enable extensibility in Formwork CMS. The changes allow plugins to hook into application lifecycle events, provide namespaced assets and views, and extend core functionality.

Key Changes:

  • Event system with dispatcher and lifecycle events (page operations, routing, exceptions, responses)
  • Plugin infrastructure with automatic event listener discovery, manifest support, and resource loading
  • Namespaced asset and view resolution (e.g., @panel/css/panel.min.css, @panel.users.index)

Reviewed changes

Copilot reviewed 113 out of 115 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
formwork/src/Events/* New event system with EventDispatcher and Event base class
formwork/src/Plugins/* Complete plugin infrastructure including Plugin, Plugins manager, PluginFactory, and PluginManifest
formwork/src/Assets/Assets.php Refactored to support namespaced asset resolution with multiple resolution paths
formwork/src/View/View.php Updated to support namespaced view resolution with @namespace.view.name syntax
formwork/src/Cms/App.php Integrated event dispatching at key lifecycle points and registered new services
formwork/src/Router/Router.php Added action parameters support for dependency injection
formwork/src/Utils/Str.php Added case conversion methods (toCamelCase, toDashCase, toSnakeCase)
formwork/src/Services/Loaders/* New service loaders for Assets and Plugins
panel/views/**/*.php Updated all panel views to use namespaced syntax (@panel.*)
formwork/views/**/*.php Updated system views to use namespaced syntax (@system.*)
formwork/config/system.yaml Added plugin configuration section
.gitignore Excluded plugin-related directories
formwork/.php-cs-fixer.php Excluded site/plugins from code style checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formwork/src/Utils/Str.php
Comment thread formwork/src/Assets/Assets.php
Comment thread formwork/src/Assets/Assets.php Outdated
Comment thread formwork/src/Plugins/PluginFactory.php
Comment thread formwork/src/Plugins/Plugins.php
Comment thread formwork/src/Plugins/Plugin.php
Comment thread formwork/src/Router/Router.php Outdated
Comment thread formwork/src/View/View.php
Comment thread formwork/src/Utils/Str.php
Comment thread formwork/src/Plugins/Controllers/AssetsController.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 114 out of 116 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formwork/src/Assets/Assets.php
Comment thread formwork/src/Plugins/Plugin.php
Comment thread formwork/src/Plugins/PluginFactory.php
Comment thread formwork/src/Utils/Str.php
Comment thread formwork/src/View/View.php Outdated
Comment thread formwork/src/Plugins/Plugin.php
Comment thread formwork/src/Panel/Panel.php
Comment thread formwork/src/Plugins/Controllers/AssetsController.php Outdated
@giuscris
giuscris force-pushed the feature/events-and-plugins branch from fe92928 to aa1b754 Compare December 7, 2025 15:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 113 out of 115 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formwork/src/View/View.php
Comment thread formwork/src/Plugins/Plugins.php Outdated
Comment thread formwork/src/Panel/Panel.php
Comment thread formwork/src/View/View.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 113 out of 115 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris
giuscris marked this pull request as ready for review December 7, 2025 20:45
@giuscris
giuscris merged commit 572b157 into 2.x Dec 7, 2025
7 checks passed
@giuscris
giuscris deleted the feature/events-and-plugins branch December 7, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants