Re: 3.0.x - defaultConnectionName not working in Plugin
*sigh* i guess i still need help here, but with the routing, not the DB connection. i want to preserve the original way i was accessing my general-purpose Controller: /captchas/whatever. i'm generally confused by routing, but AM reading the docs trying to figure it out. i know i *don't* want to use /thook/websites/captchas to get to this Controller. It's just a validation AJAX call, and besides, having the extra path segments in there feels awkward to me. Trying to follow these: http://book.cakephp.org/3.0/en/plugins.html#plugin-configuration http://book.cakephp.org/3.0/en/plugins.html#plugin-controllers http://book.cakephp.org/3.0/en/development/routing.html#plugin-routing i've enabled the plugin's 'routes' option in *bootstrap.php* Plugin::loadAll() and i have this in my *plugin*'s *routes.php*: Route::plugin('Thook/Websites', function($routes) { $routes-fallbacks(); }); i also tried adding this to the *App/Config/routes.php*: Routes::scope('/', function($routes) { // ... other routes $routes-connect('/captchas', ['plugin' = 'Thook/Websites']); // ... some other routes }); i'm unable to get the message described in the docs (Model not found) when i go to the intended URL. Instead i get Controller not found (App\Controller\ThookController). i'll keep trying, but anything toward helping me understand this better would be hugely appreciated. -joe On Saturday, 30 August 2014 01:04:22 UTC-4, Joe Theuerkauf wrote: 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)
find all on complex model
I just need to get the details from a find all across 4 associated tables. I looked at the docs and I can get the data from 2 tables but not the other tables. I have a lessons table where I get the relevant tutor id rows to display only. This works fine. I have a lessons-students table related to the lessons table over the FK lessons id. From this lessons-students table I then a field linked to another table. lessons table (fk tutor_id but no student_id) tutors table(linked to lessons table with tutor_id) lessons_students table (linked with lessonID and has a studentID) students table(linked with studentID from lesson-students table) so if I get a row from lessons table I want the tutor name (from tutor table and I can do this now), the student name via the studentID . This is 4 tables and this is proving a headache as the docs just do simple examples. http://book.cakephp.org/2.0/en/models/retrieving-your-data.html class LessonsController extends AppController { $this-set( 'tutor',$this-Lesson-find('all', array( 'conditions'=array('Lesson.Tutor_id'= 1,'Lesson.id'='Lesson_Students.lesson_id') ) )); view ?php foreach ($tutor as $item): echo 'trtd'. $item['Lesson']['id'].'/td'; // echo 'td'. $item['Tutor']['id']['username'].'/td'; echo 'td'. $item['Lesson']['tutor_id'].'/td'; echo 'td'. $item['Tutor']['last_name'].'/td'; echo 'td'. $item['Lesson_Student']['student_id'].'/td'; echo '/tr'; endforeach; unset($item); -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: find all on complex model
I cant get the student name to appear or student id -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: find all on complex model
Looks like you are using recursive, you could try adding 'recursive' = 2 (or 3) to get deeper associations. Failing that you should look into Containable and HABTM or Has Many Through http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasmany-through If you're still having trouble if you could share your model associations and pr($item) on your query; On 30 August 2014 07:54, ajt jagguy...@gmail.com wrote: I cant get the student name to appear or student id -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Kind Regards Stephen Speakman -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: 3.0.x - defaultConnectionName not working in Plugin
What happens if you use Plugin::load('PluginName'); instead of loadAll() ? On Saturday, August 30, 2014 8:20:41 AM UTC+2, Joe Theuerkauf wrote: *sigh* i guess i still need help here, but with the routing, not the DB connection. i want to preserve the original way i was accessing my general-purpose Controller: /captchas/whatever. i'm generally confused by routing, but AM reading the docs trying to figure it out. i know i *don't* want to use /thook/websites/captchas to get to this Controller. It's just a validation AJAX call, and besides, having the extra path segments in there feels awkward to me. Trying to follow these: http://book.cakephp.org/3.0/en/plugins.html#plugin-configuration http://book.cakephp.org/3.0/en/plugins.html#plugin-controllers http://book.cakephp.org/3.0/en/development/routing.html#plugin-routing i've enabled the plugin's 'routes' option in *bootstrap.php* Plugin::loadAll() and i have this in my *plugin*'s *routes.php*: Route::plugin('Thook/Websites', function($routes) { $routes-fallbacks(); }); i also tried adding this to the *App/Config/routes.php*: Routes::scope('/', function($routes) { // ... other routes $routes-connect('/captchas', ['plugin' = 'Thook/Websites']); // ... some other routes }); i'm unable to get the message described in the docs (Model not found) when i go to the intended URL. Instead i get Controller not found (App\Controller\ThookController). i'll keep trying, but anything toward helping me understand this better would be hugely appreciated. -joe On Saturday, 30 August 2014 01:04:22 UTC-4, Joe Theuerkauf wrote: 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 →
Smarty with Cakephp 2.XX .
I would look at Twig personally. It is a really solid template library, that has syntax similar to jinja and django. It also has automatic escaping which is a key feature if you are going to use a templating library. You should be able to find a few view classes that add twig support to cakephp as well. -mark -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: 3.0.x - defaultConnectionName not working in Plugin
If Router::plugin() isn't getting you the routes you want, you can combine scope() and connect () to create the exact routes you want. Just keep in mind that all the routing data that doesn't change should be in the defaults list. For example $routes-connect('/captchas/:action/*', ['plugin' = 'Thook/Websites','controller' = 'Captchas']); Would let you connect all the actions on the CaptchasController in your plugin. -mark -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: CakePHP 3.0.0-beta1 released
There might be a few other class renames happening, but the non-internal ones should all have aliases so your code doesn't break right away. However,the aliases will likely be removed for the release candidates, just so they don't stick around for a really long time. -mark -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
CakePHP 3 - How to send X-CSRF-Token header
I do this by adding a header with a jQuery beforeSend hook. I don't have an example handy as I am not at a real computer right now. -mark -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
3.x - Custom Route Class, match()
It might be possible to remove the automatic addition of the action key. However, I suspect a few tests will need to be updated. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Dispay data from HABTM in a view
Hi , I have the odd situation where I can retrieve data from a HABTM model (from debug array)but cant actually display any of it in the view. I keep getting index undefined error for everything. I want data from both tables but it doesnt work //view doesnt work foreach ($student as $item2): echo 'td'. $item2['Lesson']['id'].'/td'; echo 'td'. $item2['Student']['first_name'].'/td'; //error undefined index //controler class LessonsController extends AppController { ... $this-Lesson-recursive = -1; $options['joins'] = array( array('table' = 'lessons_students', 'alias' = 'LessonsStudent', 'type' = 'LEFT', 'conditions' = array( 'Lesson.id = LessonsStudent.lesson_id', ) ), array('table' = 'students', 'alias' = 'Student', 'type' = 'LEFT', 'conditions' = array( 'LessonsStudent.student_id=Student.id', ) ), ); $options['conditions'] = array('Student.id' = 2); // $Item-find('all', $options); $student=$this-set( 'student',$this-Lesson-find('all', $options)); -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: find all on complex model
I am having all sorts of problems and the docs for this is just awful. I have looked into simply getting data from the linked tables and after HOURS no one can give me a working example. I can only assume that this is hard to do or maybe it cant be done? 'The relationships are Lesson (main table where fk is linked to Tutor BelongsTo) LessonsStudents (the created table with student_id,lesson_id) Students (HASTBM student) Tutors (linked to Lessons) How can I get data from Lesson, Student and Tutor table in a find? I just need an example and not a link to the docs as the docs dont have a complete controller/view example of this. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: find all on complex model
$this-Lesson-find('all', array( 'contain' = array( 'Student' , 'Tutor'))); given that your models are named as the conventions suggest You also need to attach the Containable Behaviour to your model /thomas On 30 Aug 2014, at 16:41, ajt jagguy...@gmail.com wrote: I am having all sorts of problems and the docs for this is just awful. I have looked into simply getting data from the linked tables and after HOURS no one can give me a working example. I can only assume that this is hard to do or maybe it cant be done? 'The relationships are Lesson (main table where fk is linked to Tutor BelongsTo) LessonsStudents (the created table with student_id,lesson_id) Students (HASTBM student) Tutors (linked to Lessons) How can I get data from Lesson, Student and Tutor table in a find? I just need an example and not a link to the docs as the docs dont have a complete controller/view example of this. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: 3.0.x - defaultConnectionName not working in Plugin
@José: Here's what i'm using that works on the Contact page where i need to load the Captchas model to grab a question: Works: Plugin::loadAll([ [ 'Thook/Websites' = ['routes' = true] ] ]); Also works: Plugin::load('Thook/Websites'); Doesn't work: Plugin::load('Thook/Websites', ['routes' = true]); Results in ([...] shortening the path to relevant stuff): *Warning* (2): include([...]/Plugin/Thook\Websites\config\routes.php): failed to open stream: No such file or directory [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*] *Warning* (2): include() [function.include]: Failed opening '[...]/Plugin/Thook\Websites\config\routes.php' for inclusion (include_path='.;C:\WebServer\php5\pear\pear') [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*] However, the file path it's trying to include IS valid (aside from directory separators). --- @mark In my primary routes file: Router::scope('/', function(RouteBuilder $routes) { // Some routes linking to main App Controllers, working. // Per your response: *$routes-connect('/captchas/:action/*', ['plugin' = 'Thook/Websites','controller' = 'captchas' // Also tried 'Captchas', but the other routes' controller values are lower-case working]);* $routes-connect(':controller', ['action' = 'index], ['routeClass' = 'InflectedRoute']); $routes-connect('/:controller/:action/*', [], ['routeClass' = 'InflectedRoute']); // This will be dropped for production. ;) $routes-connect('/', [ 'controller' = 'pages', 'action' = 'display', 'home' ]); }); Still receiving Controller not found when i go directly to *[host]/captchas* : Missing Controller *Error: * *CaptchasController* could not be found. *Error: * Create the class *CaptchasController* below in file: App\Controller\CaptchasController.php ?php namespace App\Controller; use App\Controller\AppController; class CaptchasController extends AppController { } Thanks a lot guys, for taking a look at this with me. -joe On Saturday, 30 August 2014 08:33:57 UTC-4, mark_story wrote: If Router::plugin() isn't getting you the routes you want, you can combine scope() and connect () to create the exact routes you want. Just keep in mind that all the routing data that doesn't change should be in the defaults list. For example $routes-connect('/captchas/:action/*', ['plugin' = 'Thook/Websites','controller' = 'Captchas']); Would let you connect all the actions on the CaptchasController in your plugin. -mark -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: find all on complex model
No this is not what you do as the Student has a HABTM relationship and I am told to do joins. Also when saying adding something I NEED the code as please dont assume by adding containable I know what your talking about or the docs explain things. I dont understand why simply getting information from 4 tables is just so complicated and where is the complete examples of this? -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.