CodeIgniter Forums
Publisher, add ability to create destination-folders - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Publisher, add ability to create destination-folders (/showthread.php?tid=81495)



Publisher, add ability to create destination-folders - haugli92 - 03-11-2022

Hei!
Ref: https://codeigniter4.github.io/userguide/libraries/publisher.html

Is it possible to add ability to create destination-folders?

protected $destination = FCPATH . 'assets/vendor/bootstrap-icons';

Currently the Publisher class validates if the directory is valid on __construct, which make it hard to do anything before the publish.

Workaround: Add custom __contruct to your Publisher-class.

BootstrapPublisher.php
PHP Code:
  public function __construct(?string $source null, ?string $destination null) {
    if(!is_dir($this->destination)) {
      mkdir($this->destination0755true);
    }
    
    parent
::__construct($source$destination);
  


Regards
Haugli92


RE: Publisher, add ability to create destination-folders - kenjis - 03-11-2022

I'm not sure it is a bug or not.
But it seems a bug.
@MGatner ?