Currently, the static:clean command does not remove empty directories after removing all the containing .html files. This looks like expected behaviour (see here and most importantly this assertion).
In the test setup, the public/static/a/b directory is left alone, and any requests to that route (static/a/b) don't fall through to PHP anymore because of the default .htaccess file Tempest ships with. Instead, people are greeted with PHP's 404 page. I expected the request to be handled by PHP again.
I can work on a fix, but first wanted to confirm whether this was expected behaviour.
TL;DR: should the static:clean command remove empty directories it leaves behind?
Steps to Reproduce
<?php
use Tempest\Http\Get;
use Tempest\Http\StaticPage;
class StaticController
{
#[Get('/test/{param}')]
#[DataProvider(ParamProvider::class)]
public function __invoke(string $param)
{
return view('test.view.php');
}
}
<?php
use Generator;
use Tempest\Http\DataProvider;
class ParamProvider implements DataProvider
{
public function provide(): Generator
{
foreach (['a', 'b', 'c'] as $param) { yield ['param' => $param]; }
}
}
$ ./tempest static:generate
- /test/a > /var/www/public/test/a/index.html
- /test/b > /var/www/public/test/b/index.html
- /test/c > /var/www/public/test/c/index.html
$ tree public/test
public/test
├── a
│ └── index.html
├── b
│ └── index.html
└── c
└── index.html
3 directories, 3 files
$ ./tempest static:clean
- /var/www/public/test/a/index.html removed
- /var/www/public/test/b/index.html removed
- /var/www/public/test/c/index.html removed
$ tree public/test # notice that the `test` folder also still exists. Should it?
public/test
├── a
├── b
└── c
3 directories, 0 files
$ ./tempest serve
# Go to http://localhost:8000/test/a in your browser, and notice that you get a 404 instead of hitting the controller.
Tempest Version
1.0-alpha4
PHP Version
8.3
Operating System
MacOS
Description
Currently, the
static:clean
command does not remove empty directories after removing all the containing.html
files. This looks like expected behaviour (see here and most importantly this assertion).In the test setup, the
public/static/a/b
directory is left alone, and any requests to that route (static/a/b
) don't fall through to PHP anymore because of the default.htaccess
file Tempest ships with. Instead, people are greeted with PHP's 404 page. I expected the request to be handled by PHP again.I can work on a fix, but first wanted to confirm whether this was expected behaviour.
TL;DR: should the
static:clean
command remove empty directories it leaves behind?Steps to Reproduce