Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [1.1.0] - 2026-06-07

### Added
- Initial release of the Trakli Plugin Engine
- Plugin discovery and registration
- Plugin management commands
- Configuration system
- Event system for plugin lifecycle
- Configurable logging: the engine logs through its own channel and minimum level (`PLUGIN_ENGINE_LOG_CHANNEL`, `PLUGIN_ENGINE_LOG_LEVEL`), independent of application logging
- Compiled plugin cache: `plugin:cache` compiles discovery results to a file loaded on boot, skipping the filesystem scan; `plugin:clear` returns to live discovery
- Dockerized development environment with make targets

### Changed
- A missing plugins directory is treated as a normal state and logged at debug instead of warning on every request
- Discovery logs a single summary line instead of one line per directory entry
- The configured plugins path is honored instead of a hardcoded one
- `plugin:enable`, `plugin:disable`, and `plugin:discover` refresh an existing plugin cache

## [1.0.0] - 2025-10-02

Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM php:8.3-cli

# Install system dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Running apt-get upgrade in a Dockerfile is generally discouraged as it makes the build non-deterministic and increases image size. Stick to apt-get update and specific package installations.

Suggested change
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
RUN apt-get update && apt-get install -y \

git \
curl \
libzip-dev \
unzip \
&& docker-php-ext-install zip pdo_mysql

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /app

# The user will be the same as the host user to avoid permission issues
ARG UID
RUN useradd -G www-data,root -u ${UID} -d /home/user user
RUN mkdir -p /home/user/.composer && \
chown -R user:user /home/user

USER user
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.PHONY: help up down install test pint pint-test lint clean restart logs shell autoload fresh setup check

help:
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'

up:
docker compose up -d

down:
docker compose down

restart:
docker compose restart

logs:
docker compose logs -f

shell:
docker compose exec app bash

install: up
docker compose exec app composer install

test:
docker compose exec app composer test

pint:
docker compose exec app composer pint

pint-test:
docker compose exec app composer pint:test

lint: pint

autoload:
docker compose exec app composer dump-autoload

fresh: down up install
@echo "Environment is ready!"

setup: fresh test
@echo "Setup complete!"

check: pint-test test
@echo "All checks passed!"
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@ Edit the `config/plugins.php` file to configure the plugin system:
return [
'path' => base_path('plugins'), // Path where plugins are stored
'namespace' => 'Plugins', // Root namespace for plugins

'log_channel' => env('PLUGIN_ENGINE_LOG_CHANNEL'), // Log channel, null = app default
'log_level' => env('PLUGIN_ENGINE_LOG_LEVEL', 'warning'), // Minimum level the engine logs at
];
```

### Logging

The engine logs through its own configurable channel and minimum level,
independent of the application's logging:

- `PLUGIN_ENGINE_LOG_CHANNEL`: any channel from `config/logging.php`. Leave
unset to use the application's default channel.
- `PLUGIN_ENGINE_LOG_LEVEL`: messages below this level are dropped. Defaults
to `warning`, so routine discovery output stays out of production logs. Set
to `debug` to trace plugin discovery and registration.

## Usage

### Available Commands
Expand All @@ -55,6 +69,27 @@ return [
- `plugin:disable {id}` - Disable a plugin
- `plugin:install {package}` - Install a plugin
- `plugin:discover` - Discover and register all available plugins
- `plugin:cache` - Compile discovered plugins into a cache file
- `plugin:clear` - Remove the plugin cache file

### Caching

By default, plugins are discovered by scanning the plugins directory and
parsing each manifest on every boot. In production, compile the result to a
cache file instead, alongside the framework's other caches:

```bash
php artisan plugin:cache
```

The compiled file is loaded on boot and the filesystem scan is skipped.
Run this on every deploy, next to `config:cache` and `route:cache`.
`plugin:enable`, `plugin:disable`, and `plugin:discover` refresh an existing
cache automatically. To return to live discovery:

```bash
php artisan plugin:clear
```

### Creating a Plugin

Expand Down Expand Up @@ -135,6 +170,19 @@ The plugin system dispatches several events that you can listen for:
- `WhileSmart\PluginEngine\Events\PluginInstalled` - Fired after a plugin is installed
- `WhileSmart\PluginEngine\Events\PluginDiscovered` - Fired when a plugin is discovered

## Development

The repository ships a dockerized environment, so PHP and Composer are not
required on the host:

```bash
make install # build the container and install dependencies
make test # run the test suite
make pint # fix code style
make check # run style check and tests
make shell # open a shell in the container
```

## License

This project is open-source and licensed under the [MIT License](./LICENSE).
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "whilesmart/laravel-plugin-engine",
"description": "Laravel plugin engine for WhileSmart applications",
"description": "A flexible plugin engine for Laravel applications",
"type": "library",
"license": "proprietary",
"package-version": "1.0.0",
"package-version": "1.1.0",
"autoload": {
"psr-4": {
"WhileSmart\\LaravelPluginEngine\\": "src/"
Expand Down
Loading
Loading