Author |
Message |
chihwen
Joined: 27 Jun 2018 Posts: 1
|
Posted: Wed Jun 27, 2018 3:57 am Post subject: Laravel v5.4 DI dependency injection decode error |
|
|
Dears:
We got a decoding error. as follows:
## Case-1:
Quote: |
production.ERROR: exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Unresolvable dependency resolving [Parameter #0 [ <optional> array $attributes ]] in class App\SystemAccount' in /var/www/ws/releases/41/vendor/laravel/framework/src/Illuminate/Container/Container.php:910
Stack trace:
|
Code: |
/**
* SystemAccount constructor.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
app('app')->instance(self::class, $this);
$this->lib = app(SystemAccountLibrary::class);
}
|
## Case-2:
Quote: |
production.ERROR: exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Unresolvable dependency resolving [Parameter #1 [ <optional> $url ]] in class DoubleService\View\Template' in /var/www/ws/releases/41/vendor/laravel/framework/src/Illuminate/Container/Container.php:910
Stack trace:
|
Code: |
/**
* Template constructor.
*
* @param ViewFactory $view
* @param string $url
*/
public function __construct(ViewFactory $view, $url = '')
{
$this->view = $view;
$this->url = $url ?: env('APP_URL');
}
|
## Our environment is:
1. ionCube Encoder v9.0.5
2. ionCube Loader (enabled) v10.2.2
3. PHP v5.6.36
4. Laravel 5.4.36
Judging from the error message that the common symptom is
When Laravel automatically performs DI dependency injection, the injected object's constructor __construct() parameter with a default value.
## Tested separately using the following combinations, but all got the same error:
1. Enable Dynamic keys and decoding.
2. Enable Dynamic keys and decoding and with --allow-reflection-all.
3. Disable Dynamic keys and decoding (--disable-dynamic-decoding).
Our current solution is to ignore the php programs that have these symptoms first, and don't encode them.
Thank you for your support in advance. |
|
Back to top |
|
 |
IC2008
Joined: 01 Oct 2019 Posts: 5
|
Posted: Mon Aug 03, 2020 10:05 am Post subject: |
|
|
same problem (on Windows) but with more recents versions of PHP 7.4 / Laravel 7 / Ioncube encoder 10.4.1
+1 |
|
Back to top |
|
 |
alastair
Joined: 23 Feb 2010 Posts: 407
|
Posted: Mon Aug 03, 2020 3:46 pm Post subject: |
|
|
@IC2008
It is best to create a ticket in our Support Help Desk at https://support.ioncube.com if you are having issues.
However, what may solve the problem is to ensure that the part of Laravel *applying* the reflection API methods getDefaultValue and/or isDefaultValueAvailable is itself encoded.
The reason for that is the way that those two reflection API methods are implemented in PHP. They work by iterating through the byte code instructions to find the instructions that set the default values for a function. However, in the encoded case that instruction will not be found when called from an unencoded file as PHP does not know that the byte code instructions are protected.
However, if they are called from an encoded file then the ionCube Loader can intercept those reflection API calls and apply its own version of those methods. That will ensure that the default value is then found.
A note about the original. posting by chihwen. In the version 9 Encoder there was an option to disable dynamic decoding (not dynamic keys) which has since been removed. However, that is irrelevant since the point is that any file applying those default value reflection API methods to encoded functions must itself be encoded. That applied even before dynamic decoding was introduced. _________________ Alastair
ionCube |
|
Back to top |
|
 |
|