How can you set a default engine when using migrations (Schema Builder)? I recently got place on a shared hosting and their default MySQL engine is MyISAM. Instead of having to rewrite all my migration files to include $table->engine = 'InnoDB' I'm wondering if you can set this as default.
Is it possible?
I don't think it is,the docs http://laravel.com/docs/schema#storage-engines. Can't find any other mentioning of db engine in the docs.
You would expect it to be possible in app/config/database.php
I manage to do it. I'm using Laravel 5.5. In the config/database.php:
'connections' => [
'mysql' => [
...
'engine' => env('DB_ENGINE', null)
],
As you may know this will fetch the DB_ENGINE var from en .env file.
So in that file I setted like this:
DB_ENGINE=MyISAM
It will work if you set the var to InnoDB also.
Related
My larave app have setup steps.
In the database configuration step, user inputs should be placed as database configuration, but i dont know how can i set custom configs for database.
I used this code, but it changes the configs temporarily and doesn't save them.
Config::set("database.connections.mysql", [
"host" => "...host...",
"database" => "...database...",
"username" => "...username...",
"password" => "...password..."
]);
Just try to change .env file or on config/database.php do your corrections
I developed a website using Yii2 Framework, and while I didn't explicitly use the Cache features, I guess it does do some things using APC as default.
The client where I published the website had uninstalled APC, since it is deprecated since v5.5 and refuse to install the extension.
My client now keeps receiving an 'unable to load dynamic library - apc.so' every time they try to save or delete a record to the database, not read.
I tried to clear the cache sub folder under the runtime folder in hopes that the website will use whatever system is available, but the error still creeps up.
They are using opcache. How can I reconfigure yii to use opcache and prevent the inability to find apc.so error?
EDIT:
This is what I have under components.
'cache' => [
'class' => 'yii\caching\FileCache',
],
If your cache is properly configured you should find something like this in the configuration file:
'components' => [
'cache' => [
'class' => 'yii\caching\ApcCache',
],
],
Now, AFAIK OpCache does not require configuration on the code level so you don't have to replace this config with something OpCache specific but there are direct cache calls in your code (hence the error) so you may want to use some available cache component anyway. In case you don't want to use any new cache component and at the same time you don't want to remove cache calls in your code use DummyCache:
'cache' => [
'class' => 'yii\caching\DummyCache',
],
EDIT:
It looks like it is not a case of Yii 2 configuration, more like a PHP configuration. Look for "unable to load dynamic library - apc.so". Probably APC is still in the PHP configuration but the library has been removed.
Related questions:
https://serverfault.com/questions/623520/php-startup-unable-to-load-dynamic-library-usr-lib-php5-20100525-apc-so
PHP APC Error Loading apc.so
APC - Unable to load dynamic library
I now set a lot of values to the session using Session::put and Session::get. If I want to use Redis throughout the application, is it true that I just need to replace all Session:: with Redis:: to make it work?
By the way, I already installed the Redis package
All you have to do is just changing your .env file :
SESSION_DRIVER=redis
and use Session::get() etc.
You should change in connfig/session.php 'driver' => env('SESSION_DRIVER', 'file'), file to redis.
Case scenario:
$dbResult = myEloquentClass::remember(60)->all();
My results are being cached, which works great for a production environment.
However, i am finding myself removing the remember method in my development environment since i don't want to cache my database results.
This results in a lot of unnecessary removal/additions of code.
Is there a way to bypass the cache globally for eloquent's remember when in development environment?
In laravel - 4 edit the app/config/local/cache.php file and set the driver to array.
<?php
return array(
'driver' => 'array',
);
For laravel 5 - edit the .env file and set the CACHE_DRIVER to array
CACHE_DRIVER=array
As posted by #bogdan,
I switch my development cache.php config file's driver to array, and works as advertised.
I have a report.php file created in app/vendors/shells folder with the following content
class ReportShell extends Shell {
var $uses = array('User');
function main() {
$userData = $this->User->find('first');
}
}
when I want to run it from app folder ../cake/console/cake report I get the following error
Error: Missing database table 'users' for model 'User'
users table does exist in db, User model as well. And the project works fine, I mean there are no issues with models, controllers, views. My cake version is 1.3
Thanks
I figured it out, the problem was that in db config instead of 'host' => 'localhost' it was necessary to write 'host' => '127.0.0.1', see also this answer
How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?