-3

I need to catch only these PHP extensions that are necessary for the app to work. The idea is removing all the PHP extensions that are not necessary for the app. Do you guys have any idea how can I do that?

The app is on PHP 8.0.14 - Laravel 8

Mikaele
  • 65
  • 7
  • Assuming extensions as in `extension=curl` in `php.ini`? 1. Disable all but obvious and follow the fail trail, or 2. Scan all your code, build an index of used classes/functions, match with extensions. -- Not aware of a native automated way to do it. – Markus AO May 04 '22 at 15:22

2 Answers2

0

I am not sure what is the question. Try this code:

$full = explode("-", "PHP 8.0.14 - Laravel 8"); // first argument is separator, in your case it's "-" sign, second argument is what needs to be separated
$extension =end($full); //gives everithing after "-" sign
$noextension = reset($full); //gives everithing before "-" sign

I think you need one of those.

Imanatas
  • 1
  • 3
0

Take a look at this project: https://github.com/maglnet/ComposerRequireChecker

It does what you are asking, based both in the dependencies you required through composer and on the code you wrote.

You can use it by running composer-require-checker check <path/to/composer.json>

The output will be something like this:

$ composer-require-checker check composer.json 
ComposerRequireChecker 4.1.x-dev@fb2a69aa2b7307541233536f179275e99451b339
The following 2 unknown symbols were found:
+----------------------------------------------------------------------------------+--------------------+
| Unknown Symbol                                                                   | Guessed Dependency |
+----------------------------------------------------------------------------------+--------------------+
| hash                                                                             | ext-hash           |
| Psr\Http\Server\RequestHandlerInterface                                          |                    |
+----------------------------------------------------------------------------------+--------------------+

By looking at it you can tell that I must include ext-hash and psr/http-server-handler to my composer's require section.

Note that although ext-hash has been shipped with standard PHP distributions for a while, it may be a good practice to include it, so if your software is being executed in a non-standard/custom distribution.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32616437) – Mike Bonnell Sep 05 '22 at 15:39