'artisan serve' is creating 'public' folders?

Hey there, trying out an updated version of our site with October v3. I found myself wrestling with some odd behavior from php artisan serve.

The first time I run this command everything is accessible as expected on localhost. However, it is creating a ‘public’ folder in the root of the project. I looked over the upgrade guide and did not see anything noted about this, unless I overlooked it.

Anyway, a subsequent run of php artisan serve will create yet another public folder, but this time within the first public folder. At this point static assets like images, js, and css stop serving until these folders are removed.

This is a new problem to me; any help in regards to it is very much appreciated.

FWIW php -S localhost:8000 seems to work as expected in the meantime.

Hi @abrenoch

The only code that generates a public folder is the october:mirror command. The serve command shouldn’t do this. For example, on a clean installation, we can see no public folder is created.

λ ls
CHANGELOG.md  SECURITY.md  auth.json      composer.lock  modules       phpunit.xml  tests   webpack.config.js
LICENSE.md    app          bootstrap      config         package.json  plugins      themes  webpack.helpers.js
README.md     artisan      composer.json  index.php      phpcs.xml     storage      vendor  webpack.mix.js

~\oc-test  (octobercms)
λ php artisan serve
October CMS development server started: http://127.0.0.1:8000
   INFO  Server running on [http://127.0.0.1:8000].

  Press Ctrl+C to stop the server

^C
~\oc-test  (octobercms)
λ ls
CHANGELOG.md  SECURITY.md  auth.json      composer.lock  modules       phpunit.xml  tests   webpack.config.js
LICENSE.md    app          bootstrap      config         package.json  plugins      themes  webpack.helpers.js
README.md     artisan      composer.json  index.php      phpcs.xml     storage      vendor  webpack.mix.js

~\oc-test  (octobercms)
λ

Could there be a plugin or theme that might be creating this directory?

Hey sorry had to change focus for a few days.

This does indeed seem to be caused by a plugin - the Renatio\DynamicPDF one seems to be the culprit. The class Renatio\DynamicPDF\Classes\SyncTemplates appears to explicitly create this directory upon being initialized in SyncTemplates:95.

class SyncTemplates
{
    public function handle()
    {
        try {
            ...

            $this->checkPublicDir();
            
            ...
        } catch (Exception $e) {
            //
        }
    }

    ...

    protected function checkPublicDir()
    {
        if (! file_exists('public')) {
            mkdir('public', 0755, true);
        }
    }

    ...
}

I may bring this up to the author and just disable that line for the time.

Thanks for the response and setting me in the right direction!

2 Likes