diff --git a/en/development/application.rst b/en/development/application.rst index e57fe27436..767f691327 100644 --- a/en/development/application.rst +++ b/en/development/application.rst @@ -63,6 +63,19 @@ global event listeners:: // Call the parent to `require_once` config/bootstrap.php parent::bootstrap(); + // CakePHP has the ability to fallback to using the `Cake\ORM\Table` + // class to represent your database tables when a related class is + // not created for that table. But using this "auto-tables" feature + // can make debugging more difficult in some scenarios. So we disable + // this feature except for the CLI environment (since the classes + // would not be present when using the `bake` code generation tool). + if (PHP_SAPI !== 'cli') { + FactoryLocator::add( + 'Table', + (new TableLocator())->allowFallbackClass(false) + ); + } + // Load MyPlugin $this->addPlugin('MyPlugin'); } @@ -74,4 +87,4 @@ each test method. .. meta:: :title lang=en: CakePHP Application - :keywords lang=en: http, middleware, psr-7, events, plugins, application, baseapplication + :keywords lang=en: http, middleware, psr-7, events, plugins, application, baseapplication,auto tables,auto-tables,generic table,class diff --git a/en/development/configuration.rst b/en/development/configuration.rst index d3a43a7ab1..736e00f838 100644 --- a/en/development/configuration.rst +++ b/en/development/configuration.rst @@ -564,36 +564,6 @@ The built in configuration engines are: By default your application will use ``PhpConfig``. -Disabling Generic Tables -======================== - -While utilizing generic table classes - also called auto-tables - when quickly -creating new applications and baking models is useful, generic table class can -make debugging more difficult in some scenarios. - -You can check if any query was emitted from a generic table class via DebugKit -via the SQL panel in DebugKit. If you're still having trouble diagnosing an -issue that could be caused by auto-tables, you can throw an exception when -CakePHP implicitly uses a generic ``Cake\ORM\Table`` instead of your concrete -class like so:: - - // In your bootstrap.php - use Cake\Event\EventManager; - use Cake\Http\Exception\InternalErrorException; - - $isCakeBakeShellRunning = (PHP_SAPI === 'cli' && isset($argv[1]) && $argv[1] === 'bake'); - if (!$isCakeBakeShellRunning) { - EventManager::instance()->on('Model.initialize', function($event) { - $subject = $event->getSubject(); - if (get_class($subject) === 'Cake\ORM\Table') { - $msg = sprintf( - 'Missing table class or incorrect alias when registering table class for database table %s.', - $subject->getTable()); - throw new InternalErrorException($msg); - } - }); - } - .. meta:: :title lang=en: Configuration - :keywords lang=en: finished configuration,legacy database,database configuration,value pairs,default connection,optional configuration,example database,php class,configuration database,default database,configuration steps,index database,configuration details,class database,host localhost,inflections,key value,database connection,piece of cake,basic web,auto tables,auto-tables,generic table,class + :keywords lang=en: finished configuration,legacy database,database configuration,value pairs,default connection,optional configuration,example database,php class,configuration database,default database,configuration steps,index database,configuration details,class database,host localhost,inflections,key value,database connection,piece of cake,basic web