Laravel with heroku -> how do I fix app_key problem? - laravel

I have been working on a Laravel application and started to push to Heroku for production testing. I am following the Heroku documentation for a laravel application and am getting the following error:
"The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."
I have been searching for similiar problems and solutions and all of which I ahve tried; they say to run:
php artisan config:clear
php artisan config:cache
even generate a new key sometimes. None of this works though. I do have a .env as well as the .env.exmaple.
this is in the app.php:
'key' => env('APP_KEY', 'hApwwlSuskUu66CxJTWzCKS17fkExEkodmJiVXbMf0Q='),
'cipher' => 'AES-256-CBC',
and equally the .env has this line after the cache:
APP_KEY=base64:hApwwlSuskUu66CxJTWzCKS17fkExEkodmJiVXbMf0Q=
What else do I do? I followed the Heroku documentation to the letter and beyond.
Reference:
Laravel 6.18.3
php: 7.3.2
composer: 1.9.3
heroku 7.22.2

Try this in your app.php
'key' => env('APP_KEY', $_ENV['APP_KEY'])
or you can also try this
app.php
'key' => env('APP_KEY')
then run
heroku config:set APP_KEY=$(php artisan --no-ansi key:generate --show)

Related

I cannot disable Laravel debug logging?

I kept running the debug logging level for some time for my application also on prod, after now 2 weeks, I wanted to disable it. So I went ahead and opend the .env variable and set APP_DEBUG=false
I did a php artisan down, php artisan cache:clear, then php artisan config:clear, php artisan config:cache and brought it back up. To be fully safe here.
I went back in the log file after a minute or so and still saw production.DEBUG appearing.
I then retried all the steps, checked the config/app.php file and made sure that nothing is wrong in there. But everything looks fine.
Then I went to my local environment and tried the same but to my surprise the application still keeps logging debug messages also on local!
I cannot get it disabled!
What I tried:
php artisan config:clear / :cache / cache:clear optimize:clear / down / up ...
I checked the app.php file, the config/logging.php but all looks fine
APP_ENV=production, APP_DEBUG=false
Then to my surprise I tried something:
I changed LOG_LEVEL=info in the .env file -> no change
I opened the config/logging.php and went to the daily section (because LOG_CHANNEL=daily) and set the 'level' entry to 'info' => IT WORKS! both on PROD and LOCAL
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'info',
'days' => 21,
],
Can someone explain to me, why this is happening?
I was under the impression that the APP_DEBUG and the LOG_LEVEL should be the key indicators for Laravel but somehow they aren't?!
Might that be related to the LARAVEL DEBUGBAR? I have it installed.
Laravel version 7, php 7.4 (local Homestead, prod apache)

Class 'Yajra\DataTables\DatatablesServiceProvider' not found

I've developed Laravel Project in my local computer.
I used Yajra Pakagebox for using bootstrap datatables on it.
Like this :
composer require yajra/laravel-datatables-oracle
php artisan vendor:publish
Then I pushed them all into Hosting Server but it displays errors like below.
(1/1) FatalThrowableError
Class 'Yajra\DataTables\DatatablesServiceProvider' not found
in ProviderRepository.php (line 208)
at ProviderRepository->createProvider('Yajra\\DataTables\\DatatablesServiceProvider')
in ProviderRepository.php (line 144)
at ProviderRepository->compileManifest(array('Illuminate\\Auth\\AuthServiceProvider', 'Illuminate\\Broadcasting\\BroadcastServiceProvider', 'Illuminate\\Bus\\BusServiceProvider', 'Illuminate\\Cache\\CacheServiceProvider', 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Cookie\\CookieServiceProvider', 'Illuminate\\Database\\DatabaseServiceProvider', 'Illuminate\\Encryption\\EncryptionServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\Notifications\\NotificationServiceProvider', 'Illuminate\\Pagination\\PaginationServiceProvider', 'Illuminate\\Pipeline\\PipelineServiceProvider', 'Illuminate\\Queue\\QueueServiceProvider', 'Illuminate\\Redis\\RedisServiceProvider', 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', 'Illuminate\\Session\\SessionServiceProvider', 'Illuminate\\Translation\\TranslationServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Yajra\\DataTables\\DatatablesServiceProvider', 'Laravel\\Tinker\\TinkerServiceProvider', 'App\\Providers\\AppServiceProvider', 'App\\Providers\\AuthServiceProvider', 'App\\Providers\\EventServiceProvider', 'App\\Providers\\RouteServiceProvider'))
in ProviderRepository.php (line 61)
The important thing is I can't execute any command on Hosting Server because it is Shared Hosting Server.
I saw many articles for solving this problem but they are all using "artisan" and "composer" command.
But I can't use this command at all.
I can only upload the source code to server with FTP.
Depending on what version of DataTables you are using, it may be simple capitalization issue. After version 8 you should use:
Yajra\DataTables\DataTablesServiceProvider
Before version 8 use:
Yajra\Datatables\DatatablesServiceProvider
Upgrade notes reference: https://yajrabox.com/docs/laravel-datatables/master/upgrade#namespace
Please run below command and try:
composer update
composer dump-autoload
php artisan config:cache
php artisan cache:clear
It is working for v#8.3
Yajra\DataTables\DataTablesServiceProvider::class,
'Datatables' => Yajra\DataTables\Facades\DataTables::class,
Please add this to the config/app.php file.
The first line goes under the "Package Service Providers" section
and the second line goes under the "Class Aliases" section
replace Datatables with DataTables
Re install with the plugin along with the buttons plugin and now it's working.
composer require yajra/laravel-datatables-buttons:^3.0
In the project's folder
rm -R vendor/
rm -R bootstrap/cache
mkdir bootstrap/cache
chmod -R 777 bootstrap/*
if your laravel version => 5.4
composer require yajra/laravel-datatables-oracle:"~8.0"
if your laravel version => 5.8
composer require yajra/laravel-datatables-oracle:"~9.0"
#config/app.php
'providers' => [
...,
Yajra\DataTables\DataTablesServiceProvider::class,
]
'aliases' => [
...,
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]
composer dumpautoload
composer install
It works for me.
Source: https://github.com/yajra/laravel-datatables[https://github.com/yajra/laravel-datatables][1]
REASON ITS NOT WORKING IS:
you installed the library. and added it in config/app.php in providers array.
don't forget to run
php artisan vendor:publish
after that.
Try below steps to resolve this issue:
Use composer show to check which version of packages you are using.
Delete all files under bootstrap/cache folder
Delete vendor folder and reinstall all packages using composer install.
all the files you know you're changing to ftp (migrations config controller...)
and replaced local files to server with ftp
/composer.json
/composer.lock
/bootstrap/*
/storage/framework/cache/*
/storage/framework/views/*
/vendor/composer/*
/vendor/autoload.php
If the problem persists, I'm need to relay the version of the Laravel.
Tested with
php artisan --version
Laravel Framework 5.4.19
In your [config/app.php] file, edit the aliases array. Change it from
'Datatables' => Yajra\Datatables\Facades\Datatables::class
to
'Datatables' => Yajra\Datatables\DatatablesServiceProvider::class

Laravel: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths

I installed Laravel and uploaded it to git
now I downloaded it
But when I'm trying to enter the site I get this error:
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
I found this answer: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. laravel 5.3
My config/app.php
'key' => env('APP_KEY'),
'cipher' => env('APP_KEY'),
I run
php artisan key:generate
my ENV file:
APP_KEY=base64:zJQUL0Kuwhb2JL6L7IJ+1UO7IUSQSw2Td40F9LNABfE=
I run composer update
but still the same error...
I tried to clear config and cache it but that didn't help.
What else can I do?
Your config/app.php is wrong, change the cipher entry to 'cipher' => 'AES-256-CBC'. You have key and cipher both pointing to the same .env variable.
The correct way of resolving this is as follows:
php artisan key:generate (Note the generated base 64 key)
php artisan config:cache
Check the .env file and confirm that the value of APP_KEY is equal to the value you noted during key:generate
Thats it!!
php artisan key:generate fixed for me . You can check the .env to be sure the APP_KEY get assigned a base64 value
APP_KEY cipher if AES-256-CBC is selected, the length must be 32 characters.
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
APP_KEY=base64:iT7PDx7j8yKVTj0AW81vTnEQmqLwnVfW => 32 characters

issue with composer when deploying using Envoyer

I'm having trouble deploying my laravel app using envoyer, the error accuer in installing composer dependencies, here it is:
Generating autoload files
Illuminate\Foundation\ComposerScripts::postInstall
php artisan optimize
[RuntimeException]
No supported encrypter found. The cipher and / or key length are invalid.
it's my first time and I'm having lots of errors and don't really know how to fix them , I'd appreciate the help thanks
You need to generate key using command php artisan generate:key
As .env is not present in production so change app.php under config file to Something like below
'key' => env('APP_KEY','base64:42KCuY7E8Zc+JHrUZFyta4yspqLAjcVZeZVvymrjZBI=')
This would solve your problem.

After upgrading laravel 5.1 to 5.2 \App::environment() always returning "production"

I upgraded laravel 5.1 to 5.2, everything looks good.
But when try to access the app environment not getting what expected.
When i dd($_ENV) this is what i get
"APP_ENV" => "vagrant"
"APP_DEBUG" => "true"
"DB_HOST" => "localhost"
But When dd(\App::environment());
"production"
P.S. even I checked in tinker: dd(env('APP_ENV')) gives me "vagrant"
but dd(\App::environment()) gives me "production".
Dont you think it is odd :(
This is wierd :(
Anyone face this problem ??
you missed a step in the upgrade process:
Configuration
Environment Value
Add an env configuration option to your app.php configuration file that looks like the following:
'env' => env('APP_ENV', 'production'),
P.S. You can check the value from the artisan command:
php artisan env
Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work
php artisan config:cache
php artisan config:clear
php artisan cache:clear

Resources