When I ran composer update OR bin/console cache:clear it had issue bellow:
Executing script cache:clear [KO]
Script cache:clear returned with error code 1
In ArrayNode.php line 331:
Unrecognized options "dir_name, namespace" under
"doctrine_migrations". Ava !! ilable options are
"all_or_nothing", "check_database_platform", "connection !! ",
"custom_template", "em", "factories", "migrations",
"migrations_paths", !! "organize_migrations", "services",
"storage".
Script #auto-scripts was called via post-update-cmd
I resolved this problem by changing:
I edited doctrine-migrations.yaml:
Befor:
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations
After:
doctrine_migrations:
migrations_paths:
'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
reference:
https://github.com/doctrine/DoctrineMigrationsBundle/blob/3.1.x/UPGRADE.md
Related
When I run " php artisan migrate " in my project the following error occurs, How can I solve the error?
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = tc_cse-infohub and table_name = migrations and table_type = 'BASE TABLE')
at F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we'll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database's errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }
``
1 F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("could not find driver")
2 F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct()
```
It could be the wrong mysql port number in your .env file. Check your .env file and make sure the port number matches the same one mysql is using, also the SQL passwords in your env file, because the laravel framework is rejecting the connection hence the error on your screen.
Edit: If you're using windows make sure your php / db extensions are enabled on your xampp / wampp configurations.
For example: ;extension=pdo_mysql.so //uncomment this line just remove ;
after that please try again for php artisan migrate
You should install PDO on your server. Edit your php.ini (look at your phpinfo(), "Loaded Configuration File" line, to find the php.ini file path). Find and uncomment the following line (remove the ; character):
;extension=pdo_mysql.so
After this restart the server and should be good to go.
Edit:
composer update
composer require doctrine/dbal
php artisan cache:clear
php artisan view:clear
php artisan route:clear
Check your .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=username
DB_PASSWORD=password
run php -m and see if it lists pdo
Firest of all, adding phpinfo to your code path find out your php.ini location
<?php
phpinfo();
?>
Since you have already uncommented MySQL extension, make sure to uncomment extension=php_pdo.dll as well in the php.ini and restart the Apache.
Before migration, make sure to run
php artisan cache:clear
php artisan view:clear
php artisan route:clear
Making adminarea in Laravel 8 / livewire 2.5 / tailwindcss: 2.2 app
I renamed file.
resources/views/layouts/app.blade.php
into
resources/views/layouts/admin.blade.php
and fixed in View/Components/AppLayout.php :
public function render()
{
return view('layouts.admin');
}
and run commands :
php artisan config:cache
php artisan route:cache
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
composer dump-autoload
but I still got error :
View [layouts.app] not found. (View: /Project/vendor/livewire/livewire/src/Macros/livewire-view-component.blade.php)
Looks like there is some default "app" ref, which raise this error?
Which is valid way t5o split my app into several layouts?
Thanks!
I'm trying to add swagger documentation on my laravel rest API. First of all, I have installed the composer require "darkaonline/l5-swagger" and then composer require zircote/swagger-php then I have run
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
but the follwuing error occures.
League\Flysystem\Exception : Impossible to create the root directory "".
at C:\xampp\htdocs\landing-temp\vendor\league\flysystem\src\Adapter\Local.php:112
108| clearstatcache(false, $root);
109|
110| if ( ! is_dir($root)) {
111| $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
> 112| throw new Exception(sprintf('Impossible to create the root directory "%s". %s', $root, $errorMessage));
113| }
114| }
115| }
116|
Exception trace:
1 League\Flysystem\Adapter\Local::ensureDirectory()
C:\xampp\htdocs\landing-temp\vendor\league\flysystem\src\Adapter\Local.php:78
2 League\Flysystem\Adapter\Local::__construct()
C:\xampp\htdocs\landing-temp\vendor\laravel\framework\src\Illuminate\Foundation\Console\VendorPublishCommand.php:235
Please use the argument -v to see more details.
What should I do to solve this problem?
For Laravel 8. Documentation says that it uses a package auto-discovery feature. But it's not true.
You have to add to your config/app.php in providers section:
L5Swagger\L5SwaggerServiceProvider::class,
Then, you have to run the
php artisan config:cache
And only then, you can run the
php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'
Versions: Laravel 6, darkaonline/l5-swagger : "6."*
Just add this line in your .env file
L5_SWAGGER_GENERATE_ALWAYS=true
Then run this command
php artisan config:cache
At the end run this command
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
This worked for me :)
composer require darkaonline/l5-swagger
For use of #SWG annotation we are going to install the following package,
composer require zircote/swagger-php
and then run this artisan command,
php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'
check your read/write permissions:
https://laravel.com/docs/8.x/installation#directory-permissions
as root:
cd /dir/to/your/laravel-app
chmod -R 750 .
chmod -R 770 ./storage
chmod -R 770 ./bootstrap/cache
And what also worked me after I checked the permissions: php artisan config:cache source or for laravel versions > 7 php artisan optimize
In staging and production environment, when I try to get my custom defined variable from .env file, it returns null. I have tried creating new Key for APP and cleared all sort of caches, but result is same.
APP_NAME="App - Staging"
APP_ENV=staging
APP_KEY=<HIDDEN_KEY>
APP_DEBUG=true
APP_LOG_LEVEL=none
APP_URL=https://staging.app.com
APP_BASE_URL="https://app-staging.app.com"
Clearing Cache
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:cache
But when using following in blade view gets nothing
env('APP_BASE_URL') returns null
It is because you have run php artisan config:cache. If you are using config:cache, your env() calls should only be made in your config files.
See here: https://laravel.com/docs/5.6/configuration#configuration-caching
This post solved my issue, I defined custom config in config/app.php
https://laracasts.com/discuss/channels/laravel/accessing-custom-environment-variable
/*
|-------------------------------------------------------------------------
| Custom config variables
|-----------
|
*/
'base_url' => env('APP_BASE_URL', 'http://localhost'),
Then in .env I definded:
APP_BASE_URL="https://app-staging.app.com"
Finally cleared the cache, worked.
In blade view
{{ config('app.base_url') }}
Yes it will return only null
If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null.
See the laravel documentation https://laravel.com/docs/5.6/configuration#configuration-caching
I've installed Debugbar for Laravel as described in the steps on the website https://laravel-news.com/laravel-debugbar; and tried to make use of the Messages feature by placing the following below in my code.
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');
But when I run my website, I get the error message from Laravel saying:
1/1
FatalErrorException in HistoryController.php line 11:
Class 'App\Http\Controllers\Debugbar' not found
I have to go like /Debugbar::info(...) or put use Debugbar at the top of my code to not get the error message. Why can't I use it straight like Debugbar::info(...)?
To be able to reference the facade without prefixing it with \ you should add
use Barryvdh\Debugbar;
to the top of your controller.
after adding setting code in /config/app.php
you can use it as a facade
app('debugbar')->info('info message');
or
debugbar()->info('message');
no need use
I think you should try this :
first you add below code in config/app.php
in provider section
'Barryvdh\Debugbar\ServiceProvider',
in aliases section
'Debugbar' => 'Barryvdh\Debugbar\Facade',
after you should clear the cache like:
php artisan config:cache
php artisan cache:clear
php artisan config:clear
Hope this work for you !
Firstly, Go to the terminal and install by typing:-
composer require barryvdh/laravel-debugbar
In second step, Check your laravel verision:-
php artisan --version
In third if your laravel version is greater than 5(Laravel 5.x)
add the ServiceProvider to the providers array in config/app.php
Barryvdh\Debugbar\ServiceProvider::class,
add this to your facades in app.php:
'Debugbar' => Barryvdh\Debugbar\Facade::class,
Finally, published vendor configuration by command:-
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
After vendor published clear cache,route,view by command
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan dump-autoload -o