CodeIgniter Forums
Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 (/thread-78651.html)



Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - myo - 02-20-2021

Hi,
Mostly I have been using CI without composer by directly downloading. Today I wanted to add TWIG so I decided to use composer. 
To my surprise the number of loaded files increased by 25 even in PRODUCTION environment. 

I am sure I dont need Kint in production & as I am not hosting my app on multiple PHP versions so I dont need POLYFILL as well. I also dont need many other needlessly loaded files as shown below.

Kindly advise how to disable their autoloading in Production Environment?

Following is list of files as mentioned above:

 - D:\dev\vendor\symfony\polyfill-php80\bootstrap.php
 - D:\dev\vendor\phpstan\phpstan\bootstrap.php
 - D:\dev\vendor\symfony\polyfill-ctype\bootstrap.php
 - D:\dev\vendor\phpunit\phpunit\src\Framework\Assert\Functions.php
 - D:\dev\vendor\symfony\deprecation-contracts\function.php
 - D:\dev\vendor\symfony\polyfill-mbstring\bootstrap.php
 - D:\dev\vendor\symfony\polyfill-php73\bootstrap.php
 - D:\dev\vendor\symfony\var-dumper\Resources\functions\dump.php
 - D:\dev\vendor\symfony\polyfill-intl-grapheme\bootstrap.php
 - D:\dev\vendor\symfony\polyfill-intl-normalizer\bootstrap.php
 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\autoload.php
 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\Autoloader.php
 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\RewriteRules.php
 - D:\dev\vendor\myclabs\deep-copy\src\DeepCopy\deep_copy.php
 - D:\dev\vendor\phpseclib\phpseclib\phpseclib\bootstrap.php
 - D:\dev\vendor\symfony\string\Resources\functions.php
 - D:\dev\app\Config\Kint.php
 - D:\dev\vendor\kint-php\kint\init.php
 - D:\dev\vendor\kint-php\kint\src\Kint.php
 - D:\dev\vendor\kint-php\kint\src\Utils.php
 - D:\dev\vendor\kint-php\kint\init_helpers.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\Renderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\RichRenderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\CliRenderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\TextRenderer.php


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - kenjis - 02-20-2021

Try
Code:
composer install --no-dev



RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - iRedds - 02-20-2021

Code:
composer install --no-dev
composer update --no-dev
composer require package/name --update-no-dev



RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - myo - 02-21-2021

(02-20-2021, 09:25 PM)iRedds Wrote:
Code:
composer install --no-dev
composer update --no-dev
composer require package/name --update-no-dev

It means PRODUCTION environment option in .env file is useless?

So it means I have to keep 2 copies, 1 for local development & 1 for production?

Cant I just comment the relevant lines in composer autoload file in production?


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - iRedds - 02-21-2021

(02-21-2021, 06:06 AM)myo Wrote: It means PRODUCTION environment option in .env file is useless?

So it means I have to keep 2 copies, 1 for local development & 1 for production?

Cant I just comment the relevant lines in composer autoload file in production?

The .env file only affects the application.
You can run composer with the keys listed above on the production server.
No second copy is required.

If you mean composer.json, then it doesn't support comments.
If we are talking about files generated by the composer, the files will be recreated upon update / add / remove.


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - ojmichael - 02-21-2021

Assuming you're using Docker, the composer commands listed above should be part of your Dockerfile, and you don't need to include the vendor folder in the image.


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - myo - 02-21-2021

(02-21-2021, 08:48 PM)ojmichael Wrote: Assuming you're using Docker, the composer commands listed above should be part of your Dockerfile, and you don't need to include the vendor folder in the image.

No I am not using Docker

(02-21-2021, 03:34 PM)iRedds Wrote:
(02-21-2021, 06:06 AM)myo Wrote: It means PRODUCTION environment option in .env file is useless?

So it means I have to keep 2 copies, 1 for local development & 1 for production?

Cant I just comment the relevant lines in composer autoload file in production?

The .env file only affects the application.
You can run composer with the keys listed above on the production server.
No second copy is required.

If you mean composer.json, then it doesn't support comments.
If we are talking about files generated by the composer, the files will be recreated upon update / add / remove.
Still after composer update --no-dev and running in Production Environment I still found following files included.
So Kint Polyfill is not going away ! 

 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\autoload.php
 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\Autoloader.php
 - D:\dev\vendor\laminas\laminas-zendframework-bridge\src\RewriteRules.php
 - D:\dev\vendor\phpseclib\phpseclib\phpseclib\bootstrap.php
 - D:\dev\vendor\symfony\polyfill-ctype\bootstrap.php
 - D:\dev\vendor\symfony\polyfill-mbstring\bootstrap.php
 - D:\dev\vendor\kint-php\kint\init.php
 - D:\dev\vendor\kint-php\kint\src\Kint.php
 - D:\dev\vendor\kint-php\kint\src\Utils.php
 - D:\dev\vendor\kint-php\kint\init_helpers.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\Renderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\RichRenderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\CliRenderer.php
 - D:\dev\vendor\kint-php\kint\src\Renderer\TextRenderer.php


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - kenjis - 02-21-2021

How about this?

Remove the line "kint-php/kint": "^3.3", in composer.json.
And run `composer update --no-dev`.


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - iRedds - 02-22-2021

kint-php and laminas these are the framework dependencies

"kint-php/kint": "^3.3",
"laminas/laminas-escaper": "^2.6" => laminas/laminas-zendframework-bridge


RE: Unnecessary Files Loaded in Production Environment - Codeigniter 4.1.1 - paulbalandan - 02-22-2021

Kint and Laminas are needed dependencies. Removing those will make CI4 break. In `system/CodeIgniter.php` there is a whole method dedicated to initialize Kint, so don't meddle with that. As for symfony polyfills and phpseclib, they may be needed dependencies of those two. So removing those will break those two dependencies and in turn break CI4 ultimately.