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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Replaced the `gifexception:optimize` command and `bin/optimizer.php` by the `castor optimize` task
* Upgraded the test suite to PHPUnit 11
* Fixed a `TypeError` when the exception code is not an integer
* Moved to the standard bundle directory structure (`src/`, `public/`) and `AbstractBundle`, the `GifExceptionExtension` class has been removed

## 1.11.1 (2026-05-26)

Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ If you want to manually test the error page, you can start the demo application
by running the following command:

```shell
cd tests/app && bin/console assets:install && symfony serve
castor serve
```

It requires the [Symfony CLI](https://symfony.com/download).

Then open your browser at the displayed url (something like [http://127.0.0.1:8000](http://localhost:8000/).
You can now browse urls like [http://127.0.0.1:8000/error-XXX](http://localhost:8000/error-404)
where XXX is the HTTP status code you want to test.
Expand Down
43 changes: 0 additions & 43 deletions DependencyInjection/GifExceptionExtension.php

This file was deleted.

18 changes: 0 additions & 18 deletions GifExceptionBundle.php

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The GhostBuster of your exception page!
It displays a GIF instead of Symfony's ghost on exception page and it's compatible with Symfony versions from 6.4 to 8.2.
Here is what it looks like :

![Demo Symfony 4.4](Resources/doc/images/demo.gif)
![Demo](docs/demo.gif)

*Be aware that we can not be held responsible for any loss of productivity during development.*

Expand All @@ -29,7 +29,7 @@ Now enjoy your exceptions \o/
## Add some more gifs!

We need you to improve the included GIFs! Do not hesitate to open PRs to add
more gifs in [Resources/public/images/](Resources/public/images/), it will be very welcomed! :wink:
more gifs in [public/images/](public/images/), it will be very welcomed! :wink:

## Optimizing gifs

Expand Down Expand Up @@ -57,6 +57,7 @@ castor cs # Fix PHP coding standards
castor cs --dry-run # Check PHP coding standards
castor phpstan # Run static analysis
castor optimize # Optimize and resize gifs
castor serve # Start the demo application
```

## Further documentation
Expand Down
31 changes: 0 additions & 31 deletions Resources/config/services.php

This file was deleted.

20 changes: 19 additions & 1 deletion castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
*/

use Castor\Attribute\AsTask;
use Symfony\Component\Process\ExecutableFinder;

use function Castor\context;
use function Castor\io;
use function Castor\run;

Expand Down Expand Up @@ -39,7 +41,7 @@ function phpstan(): void
}

#[AsTask(description: 'Optimize and resize gifs with gifsicle')]
function optimize(string $dir = 'Resources/public/images', int $width = 145, string $level = '-O3'): void
function optimize(string $dir = 'public/images', int $width = 145, string $level = '-O3'): void
{
foreach (glob("{$dir}/*/*.gif") ?: [] as $gif) {
$before = filesize($gif);
Expand All @@ -50,3 +52,19 @@ function optimize(string $dir = 'Resources/public/images', int $width = 145, str
io()->writeln(sprintf('%s: %d KB -> %d KB (%d%%)', $gif, $before / 1024, $after / 1024, 100 - $after * 100 / $before));
}
}

#[AsTask(description: 'Start the demo application to test the error page manually')]
function serve(): void
{
if (null === (new ExecutableFinder())->find('symfony')) {
io()->error('The Symfony CLI is required, see https://symfony.com/download');

exit(1);
}

// Run from tests/app so assets:install targets tests/app/public, not the bundle's own public dir
$context = context()->withWorkingDirectory('tests/app');

run('bin/console assets:install', $context);
run('symfony serve', $context->withTty());
}
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
"license": "MIT",
"autoload": {
"psr-4": {
"Joli\\GifExceptionBundle\\": ""
},
"exclude-from-classmap": [
"/tests/"
]
"Joli\\GifExceptionBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
Expand Down
File renamed without changes
6 changes: 1 addition & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
</testsuites>
<source>
<include>
<directory>.</directory>
<directory>src</directory>
</include>
<exclude>
<directory>tests</directory>
<directory>vendor</directory>
</exclude>
</source>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension" />
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
54 changes: 54 additions & 0 deletions src/GifExceptionBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* This file is part of the GifExceptionBundle project.
*
* (c) JoliCode <coucou@jolicode.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Joli\GifExceptionBundle;

use Joli\GifExceptionBundle\EventListener\ReplaceImageListener;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

class GifExceptionBundle extends AbstractBundle
{
public function getPath(): string
{
return \dirname(__DIR__);
}

/**
* @param array<mixed> $config
*/
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
if (!$builder->getParameter('kernel.debug')) {
return;
}

$gifs = [];

foreach (glob($this->getPath() . '/public/images/*/*.gif') ?: [] as $path) {
$gifs[basename(\dirname($path))][] = basename($path);
}

$container->services()
->set('gif_exception.listener.replace_image', ReplaceImageListener::class)
->args([
$gifs,
param('kernel.error_controller'),
service('assets.packages')->nullOnInvalid(),
])
->tag('kernel.event_subscriber')
;
}
}
2 changes: 1 addition & 1 deletion tests/GifsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GifsTest extends TestCase
{
public function testAllGifsAreResized(): void
{
$gifs = glob(__DIR__ . '/../Resources/public/images/*/*.gif');
$gifs = glob(__DIR__ . '/../public/images/*/*.gif');

self::assertNotEmpty($gifs);

Expand Down
Loading