How to use Minify in Codeigniter 4 - Namespace Issues - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: How to use Minify in Codeigniter 4 - Namespace Issues (/showthread.php?tid=77799) |
How to use Minify in Codeigniter 4 - Namespace Issues - myo - 10-20-2020 Hi, I am trying to use matthiasmullie/minify in Codeigniter 4. But so far I am getting errors due to wrong namespacing. Following is what I did so far: I copied whole unzipped folder in Library: Libraries/Mathia I added following in Config/Autoload.php PHP Code: 'MatthiasMullie' => APPPATH . 'Libraries/Mathia/src', In a controller I used following code: PHP Code: use MatthiasMullie\Minify; Then I used following code to use it but I got errors, file not found PHP Code: $minifier = new Minify\CSS(); Kindly advise how to use it correctly. Regards Note: I do not want to use composer, kindly advise how to manually integrate Minify in Codeigniter 4. RE: How to use Minify in Codeigniter 4 - Namespace Issues - captain-sensible - 10-20-2020 i think it may be your not linking a "namespace" to where classes are using namespace. Namespace of css.php is "MatthiasMullie\Minify" so you have to use that. the \ is a problem so simply escape that with another backspace. 'MatthiasMullie\\Minify'=>APPPATH.'Libraries/Mathia/src', i prefer to keep my 3rd packages separate, im using PHPMailer: Code: appstarter php mailer is at same level as app; to get it working this is my autoload: Code: public $psr4 = [ then in a controller to use it : Code: use PHPMailer\PHPMailer\PHPMailer; by the way you can use composer to get that : https://packagist.org/packages/matthiasmullie/minify then the autoload feature of composer would do class linking for you automatically RE: How to use Minify in Codeigniter 4 - Namespace Issues - captain-sensible - 10-21-2020 had another quick look; if you set it up manually you also need this package : https://github.com/matthiasmullie/path-converter let me know if your still having trouble ? RE: How to use Minify in Codeigniter 4 - Namespace Issues - myo - 10-21-2020 Thanks captain, its working fine now. I already had path converter. Issue was in namespace. RE: How to use Minify in Codeigniter 4 - Namespace Issues - captain-sensible - 10-21-2020 ok great- it shows the advantage of composer though, in that dependencies needed are installed RE: How to use Minify in Codeigniter 4 - Namespace Issues - haroldentwist - 09-09-2021 (10-21-2020, 03:58 AM)myo Wrote: Thanks captain, its working fine now. I already had path converter. Issue was in namespace. After replacing the namespace were you able to solve the problem? You didn't need a converter? |