i wasn't. My mistake. However, i guess there was more to the puzzle. Even after adding Plugin::loadAll() to bootstrap.php, it wasn't working.
i continued to tinker, finally creating a full-blown plugin (*cake bake plugin Thook/Websites*). Note the original post was just the Model commands - i hadn't created the plugin before hand. i had to make some adjustments to namespaces and the composer.json path strings. It's writing ./plugins/... instead of ./Plugin where bake actually places the plugin's directory tree, and path separators are getting mixed up. If you want more detail on that, i'll create a dummy plugin & note the mix-ups. Yes, it's Windows... ;-) Whatever i did this time, it's working. i've confirmed by pulling out all the old i don't know if it's because i'm switching between Cake 3 on this project and Zend 1 at work, or what, but my brain is pudding. Any idea how to get my IDE (PhpStorm) to recognize the namespaces correctly, since the *src/* part of the path breaks up the PSR-0/4 conformity? Just curious. The app functions Now to work on hooking up the routes & controllers... Congrats on getting to beta, by the way! -joe On Friday, 29 August 2014 04:00:35 UTC-4, José Lorenzo wrote: > > How did you load your plugin? > > On Friday, August 29, 2014 9:32:48 AM UTC+2, Joe Theuerkauf wrote: >> >> A while ago i created this thread: >> https://groups.google.com/forum/#!topic/cake-php/A5WHkiWCPd4 >> >> i was trying to hook up tables from a second database, using a different >> Datasource connection from *app.php*. >> >> My default is "kodiak", the other is "websites". It's a general-use set >> of tables, like MimeTypes, Captcha questions, etc. >> >> i got them working by putting them in together with Table/Entity classes >> from the "kodiak" database. However, i wanted to organize the class files >> for these Tables/Entities away from the other stuff, and the suggestion was >> to use a Plugin syntax. >> >> Cut to tonight: >> >> 1. i used the cake command line to build models within my plugin: >> >> >> >> *cake bake model Thook\Websites.Captchas --connection=websites*2. The >> files were built successfully within *Plugin/Thook/Websites/src*. >> >> 3. i added >> >> >> >> *public static function defaultConnectionName() { return 'websites';}*to >> each of the Table classes i built, as i had done originally under >> *App/Model/Table*. i kinda feel this part should be added automatically >> if *--connection* is specified on the command line, but the point is >> moot. >> >> 4. i changed the line in my Controller that loads the Captchas Model (per >> http://book.cakephp.org/3.0/en/plugins.html#plugin-models at the end of >> that section): >> >> *$captchasTable = TableRegistry::get('Thook/Websites.Captchas');* >> i think that's the right syntax. If i try anything else similar to it, i >> get class-not-found errors. >> >> Using that syntax, i get this: >> >> >> *SQLSTATE[42S02]: Base table or view not found: 1146 Table >> 'kodiak.captchas' doesn't exist*Error: An Internal Error Has Occurred. >> Stack Trace >> ROOT\vendor\cakephp\cakephp\src\Database\Schema\Collection.php line >> 116 → Cake\Database\Schema\Collection->_reflect(string, string, array, >> Cake\Database\Schema\Table) >> ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 323 → >> Cake\Database\Schema\Collection->describe(string) >> ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 136 → >> Cake\ORM\Table->schema() >> ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 119 → >> Cake\ORM\Query->addDefaultTypes(Cake\ORM\Table) >> ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 927 → >> Cake\ORM\Query->__construct(Cake\Database\Connection, Cake\ORM\Table) >> ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 724 → >> Cake\ORM\Table->query() >> APP/Controller\ContactsController.php line 65 → >> Cake\ORM\Table->find(string) >> (expanded...) >> $termsTable = TableRegistry::get('Terms'); >> $captchasTable = TableRegistry::get('Thook/Websites.Captchas'); >> >> *Line 65: $captcha = $captchasTable->find('random')->first();* >> So it brings me back to the same thing i was struggling with last time: >> it looks like the Table class gets loaded, but *defaultConnectionName* >> isn't doing its job to tell the App to use the 'websites' connection >> instead of 'default' (kodiak). >> >> *find('random')* is in a Table extension class i added, and was also >> working until i started trying the Plugin approach for the Model. >> >> Any help? >> >> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
