Open sidebar
//My full Facade /app/Facades/ITwrx/ITwrxCrypt.php <?php namespace App\Facades\ITwrx; use Illuminate\Support\Facades\Facade; /** * @see \Illuminate\Encryption\Encrypter */ class ITwrxCrypt extends Facade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'ITwrxCrypt'; } } -------------------------------------------------------------------------------------------------- //My nearly full Service Provider /app/Providers/ITwrx/ITwrxCryptServiceProvider.php <?php namespace App\Providers\ITwrx; use RuntimeException; use Illuminate\Support\Str; use Illuminate\Support\ServiceProvider; use Illuminate\Encryption\Encrypter; class ITwrxCryptServiceProvider extends \Illuminate\Encryption\EncryptionServiceProvider { /** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('ITwrxCrypt', function ($app) { //set custom $key, etc. //return Encrypter. return new Encrypter($key, 'AES-256-CBC'); }); } } ----------------------------------------------------------------------------------------------------- //My Command. app/Console/Commands/MyCommand.php 400+ loc not related to the problem at hand. below is the relevant code. namespace App\Console\Commands; use App\Facades\ITwrx\ITwrxCrypt; //later, inside handle() method. the below used during troubleshooting. $instance = ITwrxCrypt::getFacadeRoot(); dd($instance); //returns null. ------------------- //the below is an example of what i need to actually use. //manually decrypt value using hardcoded elocrypt prefix. $decrypted_value = ITwrxCrypt::decrypt(str_replace('__ELOCRYPT__', '', $value)); //returns 'facade root has not been set', as getFacadeRoot() returns null. ------------------------------------------------------------------------------------------------------- //Example of a controller using my facade successfully. /app/Http/Controllers/Books/Invoices/InvoicesCreateController.php many loc not related to the problem at hand. below is the relevant code. namespace App\Http\Controllers\Books\Invoices; use App\Facades\ITwrx\ITwrxCrypt; //later, inside get() method, for troubleshooting. $instance = ITwrxCrypt::getFacadeRoot(); dd($instance); //returns an instance of laravel's Encrypter class via my facade and service provider, which extends the laravel service provider, which provides the Encrypter.php class. --------------------- //the below is an example of what i actually use. //manually decrypt value using hardcoded elocrypt prefix. $decrypted_value = ITwrxCrypt::decrypt(str_replace('__ELOCRYPT__', '', $value)); //returns the decrypted value, as expected.
Close sidebar
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting