Re: The (bad) perception and image of CakePHP in the public
My 3 reasons: 1. CakePHP can integrate with legacy code. It only takes a little bit of fiddling, but it was one of the primary reasons I went for it. 2. Convention over configuration, but not at the expense of no configuration. Working with legacy databases, it was good that Models in CakePHP could be configured to work with tables that didn't fit the ideal convention. 3. Documentation / code readability. Whilst separate, if I can't work out how a feature works in the documentation, I can go to the code and work it out from there. With the exception of the events system, I find the code easy to read and navigate. Those are 3 that come to mind. Now that I've been using it for several years, there are additional reasons to stay, like my investment in learning, community, approachability of the core team. On Tue, Sep 30, 2014 at 6:28 PM, José Lorenzo jose@gmail.com wrote: Before giving my own view into this problem, you you guys list the reasons why you think CakePHP is a cool or productive framework to work with? Just give me 3 reasons, no comparisons with other frameworks On Tuesday, September 30, 2014 6:24:30 AM UTC+2, Jeremy Burns wrote: This is so true. I’m a huge fan of Cake but we do feel like the whipping boys sometimes. I recently hired someone into a project and the first thing he tried to do was change the framework for a whole bunch of vague reasons like ‘Laravel is just so much better’. Perhaps someone can devise some simple benchmarking challenges that the guardians of the various frameworks can take up themselves and then compare the actual results, rather than letting a random person do it out of the box. A competition, if you will. So, for example, write a thousand records to a database, read them back, perform some function and render them to screen. Yes, yes, I know there would need to be some element of a level playing field with server spec and the like, but it could be done. Then each framework can show it’s own best efforts and - importantly - will have no excuses about not understanding the framework or setting it up correctly. I haven’t had a ‘job’ for the past six years, but on the odd time that I decide a regular income would be nice I rarely - if ever - see CakePHP as a requirement. It’s always Symfony, Zend, Drupal, Code Ingniter, sometimes Laravel, sometimes ROR and sometimes something else. That’s awkward and I just can’t help wondering if I am swimming against a tide. Perhaps everyone else is right and I am wrong? TBH, I’m not clever enough to be able to explain why Cake is the right choice compared to others; some help there would be cool. On 30 Sep 2014, at 00:43, Reuben reuben.he...@gmail.com wrote: My apologies, dereuromark, for the incorrect spelling of your handle. On Tuesday, 30 September 2014 09:40:31 UTC+10, Reuben wrote: The few times that I've seen CakePHP compared to other PHP frameworks is in performance tests, and it never looks pretty. Usually the test is a very simple Hello World test, or an action that reads/writes a bunch of records to the database. Not really real work tests, and no effort to configure the application to make sure it's doing the best that it can (i.e. appropriate cache options, etc). There have been a few articles written on CakePHP and performance, and all the stuff you can do before complaining about the framework itself. Unfortunately, when people are comparing PHP frameworks, they just look for that performance index, and don't take too much notice of the merits of the performance test taken. My perception is that at last check, there might be room for improvement in the event model, but I don't do all the other things that can be done to get better performance out of CakePHP, before going there, so it's never been an issue for me. I also understand that start up times have been improved with CakePHP 3, and the routing configuration required. Of course, CakePHP is more than just performance of the framework. The documentation is great, the community is great and the core development team are very approachable, via groups, irc and github issues. And the code itself, should you need to look at it, is very readable. The only part that makes my brain hurt a little is the event system, especially when trying to work out, when this event is fired, what is listening for it in the CakePHP core. Maybe there could be some articles written about the CakePHP core, to make TheBakery a little more attractive to read. I'm more likely to read CakePHP articles from Mark Story, AD7six or deuromark than peruse the 1 or 2 paragraph articles on TheBakery. Regards Reuben Helms On Tuesday, 30 September 2014 07:15:54 UTC+10, Florian Krämer wrote: In the official CakePHP Facebook group Yanuar Nurcahyo asked about opinions on that link http://www.quora.com/Why- isnt-Cakephp-popular-despite-being-one-of-the-earliest-php- framework-to-be-written I'll quote my own comment
Re: How to self join?
Sorry, Sam. I realised that was a bum steer just before leaving from work, as I tried to do a similar thing and it failed. That's because when the find is issued to do the belong association, it's a separate query, and the only thing that gets passed to it from the main model is the value of the foreignKey, but that must match the primaryKey of the belongsModel. That virtualField setup wont quite work, because you can only do virtual fields on the current model. However, if you do it on the current model, then when you try to query the parent, it should be available. However, I think you're going to have to do use the joins clause. Here's my take on what the function on the model might look like. public function getNodeCounts() { return $this-find('all', array( 'fields' = array('CmsPage.name', '(count(CmsPageParent.name) - 1) as depth', 'joins = array( array( 'table' = 'cms_pages', 'alias' = 'CmsPageParent', 'type' = 'left' ) ) 'conditions' = array( 'CmsPage.lft between CmsPageParent.lft and CmsPageParent.rgt' ), 'group' = 'CmsPage.name', 'order' = 'CmsPage.lft' )); } There are a couple of notes. I'm not sure if the 'as depth' will work. You may find the depth value appears on an anonymous model, but perhaps with that field name. You may need to stick array() around the group and order clauses. I'm concerned that the joins entry doesn't have any conditions. I'm not sure if this is how you'd normally do a full table join via the from clause using joins. Failing that, just do a $db-getDataSource()-fetchAll(). Your query doesn't take any input, so there should be minimal issue with sql injection. http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#prepared-statements Regards Reuben Helms On Tue, Jun 17, 2014 at 1:03 AM, Sam Clauw i...@bellewaerdefun.be wrote: Well, it seems there are 2 problems with you suggested query. Here's the SQL error I've got: *Error: *SQLSTATE[42S22]: Column not found: 1054 Unknown column 'CmsPage.null' in 'on clause' *SQL Query: *SELECT `CmsPage`.`id`, `CmsPage`.`parent_id`, `CmsPage`.`name`, `CmsPage`.`lft`, `CmsPage`.`rgt`, `CmsPage`.`plugin`, `CmsPage`.`controller`, `CmsPage`.`action`, `CmsPage`.`show`, `CmsPage`.`sequence`, `CmsPage`.`created`, `CmsPage`.`modified`, `CmsPage`.`deleted`, `Parent`.`id`, `Parent`.`parent_id`, `Parent`.`name`, `Parent`.`lft`, `Parent`.`rgt`, `Parent`.`plugin`, `Parent`.`controller`, `Parent`.`action`, `Parent`.`show`, `Parent`.`sequence`, `Parent`.`created`, `Parent`.`modified`, `Parent`.`deleted` FROM `blwfun`.`cms_pages` AS `CmsPage` LEFT JOIN `blwfun`.`cms_pages` AS `Parent` ON (`CmsPage`.`null` = `Parent`.`id` AND `CmsPage`.`lft` BETWEEN `Parent`.`lft` and `Parent`.`rgt`) WHERE `CmsPage`.`deleted` IS NULL LIMIT 20 So, I changed my model to: class CmsPage extends CoasterCmsAppModel { public $belongsTo = array( 'Parent' = array( 'className' = 'CoasterCms.CmsPage', /*'foreignKey' = 'null',*/ 'conditions' = array( 'CmsPage.lft BETWEEN Parent.lft and Parent.rgt' ) ) ); public $virtualFields = array( 'depth' = '(COUNT(Parent.name) - 1)' ); } The only problem is now that I only got one row in return, with a wrong depth value... Somebody who knows what I'm still doing wrong? Or somebody who know how I can output all SQL statements as a string? The only code I can find is: $log = $this-Model-getDataSource()-getLog(false, false); debug($log); But I cannot do anything with that output: array( 'log' = array(), 'count' = (int) 0, 'time' = null ) -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/snf6LkO638M/unsubscribe. To unsubscribe from this group and all its topics, 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: index.php not found?
At the bottom of [ http://book.cakephp.org/2.0/en/installation/url-rewriting.html], they mention where to look if you don't or can't use URL rewriting. And after a bit of searching on that page, you'll come across [ http://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration], which mentions you must set App.baseUrl, and remove the .htaccess files if you can't or don't want to use mod_rewrite. However, I'd recommend sticking with mod_rewrite. It's the convention, and will make things simple when it comes to nice URLs (i.e., you won't have index.php in every URL). Secondly, I'd recommend a Composer setup, where CakePHP gets installed into the Vendors directory. Especially if you're using PHP 5.3 or greater. This requires a little bit more setup in CakePHP 2.5, but is well worth it. And thirdly, if you're just trying out the tuts, I'd recommend using CakePHP 3.0. Whilst not production ready, it's pretty good, and will give you an idea of things to be aware of should you decide to use CakePHP 2.5 for full development purposes (like using Composer for the install, and the changes in the Models). And the composer setup isn't as tricky as CakePHP 2.5. Regards Reuben Helms On Thu, Jun 12, 2014 at 11:02 PM, Kevin Burton ronald.kevin.bur...@gmail.com wrote: I am using version 2.5. Here is the way I have defined the document root: Alias /blog C:/Users/Kevin/cakeblog/ Directory C:/Users/Kevin/cakeblog/ Options Indexes FollowSymLinks ExecCGI AllowOverride all Require local /Directory So in the directory c:/Users/Kevin/cakeblog I have the Cake default folder structure app Config . . . . . webroot css files img js .htaccess index.php test.php lib plugins vendors So if I browse to http://localhost/blog/app/webroot/index.php I get the error message that the URL rewrite is not configured properly. If I uncomment the LoadModule line as explained at the beginning of the post I still get the error message. If I click on the 'Help me configure it' HyperLink, as far as i can tell I have the the first two stipulations correct. The third basically says that I should make sure that I have downloaded Cake from the official distribution, and that checks out. I am just trying to get the blog tutorial running. Ideas? Thank you. Kevin -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/Xk3BetZMp-g/unsubscribe. To unsubscribe from this group and all its topics, 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: Upgrading from cakePHP version 1.3 to 2.5
Depends on your need. Just look at what CakePHP does. It has a 1.3 branch, a master branch ( for 2.x range), and 3.0 for dev. When 3.0 goes stable, most likely there will be a 2.7(?) branch, and the 3.x range will be maintained on master. If your product requires multiple releases that must be maintained in parallel, then this model could be for you. If your product only has one release that needs maintaining, then merge into master when it goes live. On Tuesday, May 20, 2014, HK hkosm...@gmail.com wrote: Yes of course a branch. But after upgrade is completed will you merge it with default? or leave it as it is, and always use this branch instead of default? On Friday, May 16, 2014 2:54:10 PM UTC+3, Reuben wrote: I'd branch, at the very least. On Friday, May 16, 2014, HK hkos...@gmail.com wrote: I was wondering what to do with my mercurial in such case of a large upgrade process, especially with composer, where directory structures changes a lot . Do you start a new project or make the changes (no matter how big) to your current project on a separate branch? Thanks On Friday, May 16, 2014 8:15:22 AM UTC+3, Reuben wrote: I would also consider installing CakePHP via composer, in preparation for CakePHP 3.0. Plus is just makes dependency management and upgrades for PHP vendor code so much easier. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/cake-php/1k3_RaTDovY/unsubscribe. To unsubscribe from this group and all its topics, 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/1k3_RaTDovY/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.comjavascript:_e(%7B%7D,'cvml','cake-php%2bunsubscr...@googlegroups.com'); . To post to this group, send email to cake-php@googlegroups.comjavascript:_e(%7B%7D,'cvml','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: CakePHP 3.0-dev3 Request Routing
Ah, there you go. A new install, so I didn't look at the Migration guide. But I guess that's a good idea when looking for differences between 2.x and 3.x. I'll give it a complete read. It might fix my other issue as well. On Wed, May 21, 2014 at 9:47 AM, euromark dereurom...@gmail.com wrote: If you plan on using a dev version its always wise to take a look at the migration guide ;) See http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html#router in regardings to arguments for parseExtentions() mark Am Mittwoch, 21. Mai 2014 01:28:12 UTC+2 schrieb Reuben: Hi I don't do request router a lot, but I thought I'd try something with CakePHP 3.0, and am currently working with the dev3 release. I was under the impression that if you didnt pass any parameters to Router::parseExtensions(), then it would parse all extensions, including the basics, like xml, json and html. However, in the sample code I was writing, the xml extension was not recognised until I had Router::parseExtensions(['xml']); Here's snippets of the code I think is relevant: In routes.php: Router::mapResources('authors); Router::parseExtensions(); // Router::parseExtensions(['xml']); works in AppController.php public $components = array('RequestHandler'); in AuthorsController.php public function index() { $authors = $this-paginate($this-Authors); debug($authors); $this-set(array( 'authors' = $authors, '_serialize' = array('authors') )); } Expected URL to call: http://localhost/authors.xml Resulting error: Error: Authors.xmlController could not be found. Error: Create the class Authors.xmlController below in file: App\Controller\Authors.xmlController.php Specifying xml in parseExtensions, works after a fashion (the Controller is found, but there's still an error, which is the subject of another post. Regards Reuben Helms -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/ZDG0GVblxT4/unsubscribe. To unsubscribe from this group and all its topics, 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: Upgrading from cakePHP version 1.3 to 2.5
I'd branch, at the very least. On Friday, May 16, 2014, HK hkosm...@gmail.com wrote: I was wondering what to do with my mercurial in such case of a large upgrade process, especially with composer, where directory structures changes a lot . Do you start a new project or make the changes (no matter how big) to your current project on a separate branch? Thanks On Friday, May 16, 2014 8:15:22 AM UTC+3, Reuben wrote: I would also consider installing CakePHP via composer, in preparation for CakePHP 3.0. Plus is just makes dependency management and upgrades for PHP vendor code so much easier. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/1k3_RaTDovY/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.comjavascript:_e(%7B%7D,'cvml','cake-php%2bunsubscr...@googlegroups.com'); . To post to this group, send email to cake-php@googlegroups.comjavascript:_e(%7B%7D,'cvml','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: When is a form post not a form post?
I guess because it threw me. In most cases, I've previously checked isPost, now is('post'). In other places, I would check for data, but that's not good practice now, because GET data is also on the request. Also, when I see method=post on the form element, and POST on the HTTP call, then I would expect the method on the request to also be post. If method() is going to report PUT, then I would expect that the actual form method, and HTTP verb would also be PUT. After all, that's convention (over configuration, or code obfuscation). On Wednesday, May 14, 2014, euromark dereurom...@gmail.com wrote: I am not quite sure why you are making this into your own science project :) it is fairly simple actually have an id field in your table = edit = PUT dont have an id field in your table = add = POST That's documented - and exactly as easy and straightforward as it sounds If you don't care about PUT/POST in your actions, you can indeed just check for both (as I have always done so far): if ($this-request-is(array('post', 'put')) {} This works for all edit and add actions. Always. Done in a few seconds.. :) Am Mittwoch, 14. Mai 2014 02:09:51 UTC+2 schrieb Reuben: So, having decided to always specify the action is the Form::create, so I can only be concerns with detecting a POST for form submissions, I'd really like to make sure that is covered in my unit testing. But that's a tricky one. I guess I would need to write a unit test for any view that has a form, and mock the FormHelper to expect that any create() had an array with an action entry to specify the expected action. Writing unit tests for views is generally frowned on, so much so, that an example of how to do this is not given in the doco. If the issue holds my attention long enough, I'll post back. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/3ypcXFatKQk/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.comjavascript:_e(%7B%7D,'cvml','cake-php%2bunsubscr...@googlegroups.com'); . To post to this group, send email to cake-php@googlegroups.comjavascript:_e(%7B%7D,'cvml','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: What's the correct method for using Traits and Namespaces for CakePHP 2?
Right now, no. I was just curious. Call it professional development. I've been following the development of CakePHP 3, but have not had much time to play with it directly. So I was curious about about the namespace convention in CakePHP 3 applications, and what someone could do to ride ahead of the migration curve if they happened to be using traits, a construct where namespaces might become relevant. On Friday, January 31, 2014, José Lorenzo jose@gmail.com wrote: Do you need to use namespaces? Otherwise you can just load the file with App::uses() On Wednesday, January 29, 2014 11:50:52 AM UTC+1, Reuben wrote: Does using namespaces change anything? Or is the App::uses just to assist with loading the appropriate file? Keeping in mind CakePHP 3, if namespaces can be used, what would be the namespace convention for a CakePHP 2 application? On Wednesday, January 29, 2014, José Lorenzo jose...@gmail.com wrote: Just load the trait with App::uses() On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote: My original question on Stack Overflow [http://stackoverflow.com/ques tions/21394852/whats-the-correct-method-for-using-traits- and-namespaces-for-cakephp-2], and content copied here, should that disappear. I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait. I have a trait in Utility/VariablesTrait.php called VariablesTrait. To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3. In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place. The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well. So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/gqWZW191sHU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.comjavascript:_e(%7B%7D,'cvml','cake-php%2bunsubscr...@googlegroups.com'); . To post to this group, send email to cake-php@googlegroups.comjavascript:_e(%7B%7D,'cvml','cake-php@googlegroups.com'); . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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/groups/opt_out.
Re: What's the correct method for using Traits and Namespaces for CakePHP 2?
Does using namespaces change anything? Or is the App::uses just to assist with loading the appropriate file? Keeping in mind CakePHP 3, if namespaces can be used, what would be the namespace convention for a CakePHP 2 application? On Wednesday, January 29, 2014, José Lorenzo jose@gmail.com wrote: Just load the trait with App::uses() On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote: My original question on Stack Overflow [http://stackoverflow.com/ questions/21394852/whats-the-correct-method-for-using- traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear. I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait. I have a trait in Utility/VariablesTrait.php called VariablesTrait. To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3. In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place. The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well. So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2. Regards Reuben Helms -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/gqWZW191sHU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com javascript:_e({}, 'cvml', 'cake-php%2bunsubscr...@googlegroups.com');. To post to this group, send email to cake-php@googlegroups.comjavascript:_e({}, 'cvml', 'cake-php@googlegroups.com'); . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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/groups/opt_out.
Re: Pros and cons of Cakephp versus Laravel
I just had a quick gander at the doco. Whilst ORMs aren't never seen before features in PHP (looking at you, Doctrine), it certainly seems like Laravel is at a place where CakePHP 3 is going to take existing CakePHP users. PHP 5.4 using namespaces, location services implemented at static functions on the model (CakePHP 3 will split the 2.x Model into Table/Entity) and a fluent API. The big difference might be that Laravel is built using Symphony components, so it's a framework on a framework, where as CakePHP doesn't depend on other PHP components, other than composer (as does Laravel). Had Laravel existed in late 2008 when I went looking for a PHP MVC framework that I could integrate with legacy applications, then I might have easily gone with Laravel instead. Although, from memory, Symphony was a little bit all or nothing back then, and I'm not sure that any other framework built on top of it would have been any more flexible. On Mon, Jan 20, 2014 at 3:40 PM, Cesar Felipe cesarfel...@gmail.com wrote: The thing that I like more about cakephp is it is simple for a beginner programmer like me, before I had tried many frameworks but cakephp I was the only that made sense for me. (I'm not a programmer genius) 2 months ago I tried laravel and it was simple to understand like cakephp plus had many features never seen before in PHP like the ORM system. Now I'm using laravel in all my new projects. On Sunday, January 19, 2014 7:17:27 PM UTC-7, Sam wrote: Dear Cakephp gurus, I have used cakephp in a past project (simple one) and I would like to continue using cakephp in a new project. There are some voices which advocate using Laravel which is an up-and-coming php framework. For experienced programmers who know something about both frameworks, could you tell me what are the pros and cons? Since I use cakephp before, here are my comments about cakephp; Pros - It uses convention over configuration I like this because I am forgetful. If the framework uses configuration over convention, I may miss out things to configure when things are changed or added to the code. Cons - It does quite a bit of magic in the background(can be good or bad) and loses flexibility in the process. If the programmer wants to do special things, he may have to fight cakephp. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/KvA7AYFLx6g/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out.
Re: Looking for Help with Cakephp basics .. aka looking for a mentor
When I get back from my Christmas break, I'll have a look at a bit of code I usually stick in my AppController or AppModel (it's been that long, I cant quite remember where it sits), but basically, it uses convention to recognise a file upload, and will save the file contents to a database field. For a Search tool, I'd recommend Lucene for indexing, and do local HTTP calls to get the search results. I think Zend may even have a PHP lib to assist with Lucene, but at some point, you're going to have to get your hands dirty and actually set it up (it's Java based). Actually, scratch that.. use Apache SOLR. It sits on top of Lucene, and provides the HTTP API. Pagination is pretty simple. The Pagination component assist with defining the query, and getting the data. The Pagination Helper assist with display of numbers and first, last, next, previous options. I usually do an element to roll all those things into one call from the view. Breadcrumbs are easy if a page is only available from one menu option. They can get a bit trickier if a page can exist at two menu options, and you don't know which one ( I give you the mess that is Joomla's ItemID, used to identify a page displayed on a particular menu). Anyway, you have a good Christmas, too. On Sat, Dec 21, 2013 at 2:12 AM, Silver Troy educatedr...@gmail.com wrote: Hello Reuben, I want to thank you for that well thought reply, the answers and pointers you have given me. I really do try and find the answers through google, the cook book, youtube and irc. I just know that sometimes people can answer your question in a couple minutes that will save you hours of wasting your time. I have read through the cook book a few times already and though it does give some basic examples it lacks answering common problems. I have done the blog tutorial, expanded it with Andrew Perkins youtube tutorials to add in authorization. I have built a basic administration section and a user account section with routing (that took way too much time messing around). I have been able to create form dropdowns that get populated from other models, and I recognize the data['User']['purchased']['year'] from the examples. I have built a number of different sections like products, manufacturers, dealers, deals, users using the basic scaffolding. I do need to get into the Category Tree Structure, which I have looked into a number of examples, going to need to implement Pagination, Breadcrumbs and a proper Search tool (that works with multi-word searches). Not to mention uploading multiple images for a product with a main (or default) image set. I have been looking into using a plugin to do the image upload but that has been challenging to get one installed and working properly. The next time I post .. I will keep it to one problem and try and layout what I have done. Have a good Christmas. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/OsnN5POIi3w/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out.
Re: Production and Development Environment
Trying one more time... The requirement is that in production, you need to authenticate to get access to the API, and that in development, no authentication is required. The assumption is that the authentication will be session based, with a form based login action. There has been mention of a .htaccess file, but it wasn't clearly stated if this was used to provide authentication via Basic Authentication. In the AppController, I would have: public function beforeFilter() { /* set up Authentication */ if (!Configure::read('developmentMode')) { $this-Auth-deny(); /* a default deny for all actions, when not in developmentMode */ } else { $this-Auth-allow(); /* a default allow for all actions, when in development mode */ } } And then in any controller, I would have: public function beforeFilter() { parent::beforeFilter(); /* the remainder of your code, to allow actions, and lift authentication restrictions for particular actions */ } In production, this will ensure that all actions are denied by default, to be overridden by specific controllers. In development, this will set up a default allow for all actions. It's been a while since I've actually played with the CakePHP 2.X Auth stuff, but that's the general idea I was going for. Best of luck finding a solution. Regards Reuben Helms On Tue, Dec 3, 2013 at 8:39 AM, Advantage+ movepix...@gmail.com wrote: I appolagize. But if parent::before filter is called in the controller and reads production or development anything called after that will be over-ridden no? You cannot get an API called back to a password protected folder so you have to remove the password protection, but if you want it to be a hidden folder which is not accessible you need a way to hide it. *Dave Maharaj* *Freelance Designer | Developer* [image: Description: header_logo] www.movepixels.com | d...@movepixels.com | 709.800.0852 *From:* cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] *On Behalf Of *AD7six *Sent:* Saturday, November 30, 2013 11:08 AM *To:* cake-php@googlegroups.com *Subject:* Re: Production and Development Environment On Friday, 29 November 2013 05:45:50 UTC+1, advantage+ wrote: Hmm sounds like the exact thing I said……..and if you do Beforefilter::parent () in the controller what was the point of asking if there is an easy way to no go thur every controller! Example:: public function beforeFilter() { parent::beforeFilter(); $this-Auth-deny(); //Allow Security to allow ajax request for these actions $ajax_request = array('manage_add', 'manage_edit', ' manage_delete'); if(in_array($this-params['action'], $ajax_request)){ $this-Security-unlockedActions = $ajax_request; $this-Security-csrfCheck = false; } } Since parent:: is called you have to go thru every controller no? If you see a correct way I happy to hear about it. Thanks, Dave. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/qY0yLORk4MM/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out. image001.jpg
Re: Production and Development Environment
You don't have to go through every controller. Just on the one controller, the AppController, for the default deny, and the code that will skip that deny if you have a config that suggests you're in a development environment. The only other Controller to touch will be the controller that looks after your login action, for which you'll want an accept after parent::beforeFilter(). On Fri, Nov 29, 2013 at 2:45 PM, Advantage+ movepix...@gmail.com wrote: Hmm sounds like the exact thing I said……..and if you do Beforefilter::parent () in the controller what was the point of asking if there is an easy way to no go thur every controller! And that would not solve the problem either and if you took a few seconds to read the question Its clearly states no to go thru every controller @simon - rookie ass fool -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/qY0yLORk4MM/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out.
Re: Production and Development Environment
For that, you set up a deny by default in the AppController, and then override with specific allows in specific controllers. And then in development, where you seem to want unfettered access, just remove the global deny, so everything is allowed. (or used a config to denote it's the development environment, and by pass the global deny if it is). On Thu, Nov 28, 2013 at 7:47 PM, Advantage+ movepix...@gmail.com wrote: I want to say mode= production so no access but login And not go thru every controller and deny() that’s what I am asking. Nothing to do with ajax *Dave Maharaj* *Freelance Designer | Developer* [image: Description: header_logo] www.movepixels.com | d...@movepixels.com | 709.800.0852 *From:* cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] *On Behalf Of *Reuben *Sent:* Thursday, November 28, 2013 12:53 AM *To:* cake-php@googlegroups.com *Subject:* Re: Production and Development Environment I'm assuming that's some sort of Ajax API that you're doing? You could make your Javascript aware that it's in a development environment, and pass the Authorization token, as per http://coderseye.com/2007/how-to-do-http-basic-auth-in-ajax.html. If you're using jQuery.ajax, you can pass the username and password for Basic Authentication, but that leaves you a bit open. Also, it only sends the info when challenged with a 401, so explicit header setting might be your only option. [ http://stackoverflow.com/questions/5507234/how-to-use-basic-auth-and-jquery-and-ajax ] You could update the programming to only require authentication for non-ajax requests, but that might be defeating the purposes as well. Of course, I'm assuming that your application would normally use Form authorization in production, but you've got the added layer of Basic authentication in development. This issue should only happen when calling the API from a different domain. If the browser that is already authorized, is calling the APIs on the same domain, then the Authorization token bshould/b be sent automatically. I'm emphasizing that should, because it would just seem screwy if it didn't. On Thursday, 28 November 2013 09:48:42 UTC+10, advantage+ wrote: Building a site on client's server and password protected but now adding in API functionality and the htaccess is blocking responses back from the API calls since they can't reach the site. Is there a simply way to define production / development to allow access without password protecting the site. I do not want to go thru all 65 controllers and re-code $this-Auth-deny() / allow();. Thanks *Dave* -- 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/groups/opt_out. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/qY0yLORk4MM/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out. image001.jpg
Re: Best Practice Question - Components
I would say that calculations, and verification of amounts would be perfect functionality to place on the model. You wouldn't normally need a controller to determine the sum of items in an order, so why put it in a controller. For a shopping cart, you still might use a model to store the cart contents and cart items. You might query the cart to see what the total value is. This is not a calculation that the controller would need to make, so you wouldn't need to do it in a component either. All business logic for an entity should stay with the entity, and the model is the perfect place for that. What you might put in the component is functionality to load a cart that is attached to the session, or clear the cart from the session, if the user requests it, or save cart modifications to the session at the end the controller lifecycle. Interesting to note, in CakePHP 3.0, the model will be split between an Entity and a Table. The Table will take care of the schema, and typical database/CRUD operations, while the Entity will concentrate more on the business logic side of things. Regards Reuben Helms On Thu, Nov 7, 2013 at 10:08 AM, Kristen M littl...@gmail.com wrote: Yeah, the point of the exercise is to do things the Cake Way and take advantage of all things automagical and Cake. ;) After puzzling over the docs for a bit and realizing it's not bad form to have a controller use multiple models, I decided that splitting the existing classes into a model and a component was probably the correct solution. The model handles all the data, while the component contains common functions all controllers that use the model will need, like calculations and verification of amounts. -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/M6i0tin0b5Q/unsubscribe. To unsubscribe from this group and all its topics, 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/groups/opt_out. -- 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/groups/opt_out.
Re: Cake 2: Very confusing docs/tutorials... Is there another foolproof source?
With regards to admin routing, it looks like you're interested in doing prefix routing. As listed here [ http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing], you'll need to do the following: Set up admin as a routing prefix in app/Config/core.php Add the admin_ prefix to any controller functions that should only be accessible via the admin URL (i.e. /admin/users/index would have a admin_index() in UsersController, and corresponding app/Views/Users/admin_index.ctp) That is all you should need to do, though if you want to set up /admin to default to a specific page, then use the second code example in the link (the one setting up Router::connect('/admin', ... ). Should I have a separate login code for my administration section ? That's an application specific question, rather than a framework question. A framework question would be How can I implement distinct authentication for my admin routes? (assuming you've decided that is what you want to do). That one I can't answer, because I've never had to do it. I usually have roles associated with the user, and if they have an Administration role, or something similar, I will redirect to the /admin URL when the user logs in. Development is easier if there's just one list of users, however, if you have a business requirement for seperate logins, you may even want to consider having a separate administration app and use plugins for functionality that is common between the public and the admin apps. By having individual apps, you won't need to be concerned with admin routing, either. Should I be creating an AdminController or do I still admin functions in all my controllers (aka admin_index,admin_edit,admin_delete). For the sake of argument, lets say you are sticking with a single app for public and admin, and you have prefix routing working, then you shouldn't need an AdminController. It should be enough to just prefix controllers. Plus, if you has an AdminController that handled all admin actions, it would end up being a bit of a god object, and when it comes to maintenance, you will have a bad time. You'd have to have an index for each model you want an index for, and that would start to break convention, and get you in a bad mood when nothing works they way you expect it to work. How to build a category manager in the administration section ? Should I be using someone's plugin/helper from github ? If you can find a category manager that does the job for you, does what you want/need and has the appropriate license, then use it! If you find a helper that does what you need or help, use that too! As with any software, it's your judgement call as to other things like support, and trustworthyness. At the very least, have a look at the source code to see how it works, and if it is doing anything nefarious or has security holes. I've found the examples in the book very handy. I've also found the tests in CakePHP handy, if you're wondering how to use a particular function. CakePHP is a tool. It's a mallet, it's a brick, it's a trowel, it's mortar, it's wood, it's nails. It's up to you to put those things together make the application. I'd welcome you to take a look at other MVC frameworks such as Symphony2, Code Igniter, ASP.NET MVC and Django (to name a few), and see if they give you the same answers you're after with CakePHP. MVC development is all much of a sameness, with quirks between the different frameworks. I reckon CakePHP does a lot of things right, and gets better with each release. On Wed, Oct 30, 2013 at 11:41 PM, Silver Troy educatedr...@gmail.comwrote: I have been reading the cakephp book, looking on youtube, googling any examples I can for the past 3 weeks. Feel like I am banging my head against the wall and could easily do this stuff outside the framework. The documentation is lacking real examples that beginners could actually build on. I have hacked together a front end to my test website, a front end user section and an admin section (still can't route to it properly). Should I have a separate login code for my administration section ? Should I be creating an AdminController or do I still admin functions in all my controllers (aka admin_index,admin_edit,admin_delete). How to build a category manager in the administration section ? Should I be using someone's plugin/helper from github ? They should really attempt to put together a tutorial site that shows more than the blog example. A website that has a user registration, login, profile section. Listing of products or articles and an administration section would be something very valuable to all beginners. I do see the potential benefits of cakephp but finding decent best practices (examples) on the internet is pretty bad. Considering cakephp 2.x was released 2 years ago or so? Not to mention I am already reading about cakephp 3.0 . Maybe a concentrated effort to develop 20,50, 100 best practice examples
Re: Defining Plugin
What options did you end up using? On Tuesday, October 29, 2013, Ed Propsner wrote: I was able to work everything out using $this-paginator options(). I appreciate the help :) On Mon, Oct 28, 2013 at 2:17 AM, Ed Propsner crotchf...@gmail.com wrote: You're absolutely right, I was definitely confusing the two. I suppose that I'm so used to referencing the plugin as camel-case everywhere else within the app and since functions are camel-case and they are referenced as such in the URL, it wasn't a far stretch to make the mistake of constructing my links with *'plugin' = 'SomePlugin'*. I definitely learned my lesson on that one. I have everything fixed in the app except for pagination. It loads the first :page fine but still assumes on the following :pages the plugin should be loaded as camel-case instead of underscore. Is there something I missed when changing everything over, or is there some place I should let Cake know that those pages belong in some_plugin? I noticed that when the error is thrown the error log shows the plugin as null. On Sun, Oct 27, 2013 at 6:56 PM, euromark dereurom...@gmail.com wrote: Yes, I guess you have been creating non-conventional links so far. Mainly because you are confusing framework internal naming schemes with URL naming scheme The latter defines everything underscore_lowercased, even the plugin. The first refers mainly to classes, which will always be named CamelCased. You need to understand the difference in order to not write faulty code - which at some point can blow up (as it then did). Am Samstag, 26. Oktober 2013 04:43:11 UTC+2 schrieb CrotchFrog: I've noticed recently some strange behavior when it comes to naming conventions and Plugins. For example if I create a link somewhere within a plugin ie. *$this-Html-link('Some Link', array('controller' = 'controller', 'action' = 'action')); * Following the link would land you on the page * app/plugin/controller/action *u**nless a location is specified outside of the current plugin and controller. Links created this way and that have been working since they were created sometimes out of the blue throw an error along the lines of *SomePluginController *cannot be found. This is strange because the link has always worked in the past. When these links create an error I have to re-create the link and specify the plugin *$this-Html-link('controller' = 'controller', 'action' = 'action', 'plugin' = 'some_plugin')*. I have to use an underscore in the plugin name, using camel case results in the same error. It's possible that some, but not all, of the links were created only specifying the action and not the controller. With this being the case I could sort of understand the resulting error but not when I have specified both the controller and the action. I created all of my custom routes with the plugin as camel case, it just seems to be links and redirects that display this behavior. I assumed that with sticking to naming conventions I could write it as *SomePlugin *or *some_plugin *and either one would be fine. Have I been creating my links incorrectly this entire time? -- 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 a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/zDwuUhlVGzE/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send em -- 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/groups/opt_out.
Re: Where to place this logic?
My experience with unit testing in CakePHP is minimal. However, I do believe it should be possible. CakePHP has nice classes for assisting with testing the specific cases of Controllers (ControllerTestCase) and creating fixtures (CakeTestFixture) for using with model testing. They also provide the CakeTestCase, which is an extension of the PHPUnitTestCase (or whatever the proper PHPUnit test case class is called). I believe you should be able to use this, just as you would if you were writing tests for a model, or a helper, or a utility. In fact, I would draw your attention to any of the test cases in Cake/Test/Case/Utility. All of these tests operate on classes that operate similar to libraries. Some are fully static, some require instances of classes. The moment of truth for your Lib classes will be when it comes to mocking objects that your Lib classes use. Things like Dependency Injection are going to be important, so you can feed your Lib classes a mocked object or mocked model in the tests and still have it operate well in the runtime environment. For this, I would recommend looking at existing tests in the CakePHP installation, especially examples like behaviours and components and helpers, that rely, in part, in external objects, but have those mocked so you can control input, and accurately place asserts on the output from your Libs. Regards Reuben Helms On Fri, Oct 25, 2013 at 8:50 PM, Anja Liebermann c...@anjaliebermann.dewrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Reuben, for the moment I opted for putting the code into a lib. So now the next question. How can I wirte tests for it? Can I do that within the CakePHP testframework? If yes, how do I call it? Is there an example anywhere? Or do I have to call phpunit test from the bash? Any hint helping me to be a good developer girl keeping the promise to always write tests woulod be appreciated! Anja Am 15.10.2013 09:28, schrieb Reuben: I can't say what is best practice, but here are things that I've done in the past. Putting in a component: For a little bit, I was shoving things that did not need to be directly in the Model, into a component. This is great, as long as you only need to access that logic from a Controller. However, if the existing logic is already in a Model, and you want to move it out, then I would not suggest the component. For me, the Component is about subtlely changing the behavior of the controller, making use of startUp, shutdownDown and the lifecycle flow. If the logic doesn't have anything to do with lifecycle of the controller, then I wouldn't bother putting it in the component. Putting in a lib: My next pattern was putting functionality into a Lib/* directory. I was particularly fond of doing this for SOAP Web Services. The controller would still call a model, but then the model would call the Web Service to perform SOAP call. The advantage was that these Web Service libraries would be available from controllers and components as well. My 2 cents. Go nuts with the structure if your app. If you have an obese model that is filled with helper functions that don't directly need services provided by the model, don't be afraid to add structure that suites you. I would create a ModelHelper directory, and then create model helper classes that the model would call as required. i.e. Model/MyObeseModel.php ModelHelper/MyObeseModelHelper.php and in MyObeseModel.php App::uses('MyObeseModelHelper', 'ModelHelper'); Then you can create a new instance of MyObeseModelHelper as you need it, or instantiate it in the constructor, so it's always available. If they're really helper methods, you might get away with having them be static, and pass the model in. At least by using ModelHelper, you avoid a Lib directory that could get filled with all sorts of cruft, and know that ModelHelper contains helpers for models. You could go one step further have have Model\Helper\MyObeseModelHelper.php. I think that might be possible with CakePHP 2.x and the App::uses() clause, and would probably do rather well in CakePHP 3.0, when we can start using namespaces properly. This might not be the best way, but it's a way, and I'd also love to hear if anyone else has a recommendation or two. Regards Reuben Helms On Sunday, 13 October 2013 23:49:14 UTC+10, acl68 wrote: Hello everybody, I have a slightly advanced question. I just build an app which at some point goes through a lot of evaluation methods to find a certain value in a heap of values. I want to follow the fat model theory also because it makes methods easier for unit tests. Now my model shows a tendency to not only become fat, but obese and I consider putting the advanced logic in another place. The question is: What could that be? Normally I would create models which would extend my obese model
Re: Poll: what do you hate about CakePHP?
Cake PHP is leaps and bounds ahead of what I used to use, but I'd like to see... * Improved support for Search Engine Friendly URLs. There are many types of SEF, and while there are already published versions of a few of them, I'd like to see some core support, so that a new revision of Cake doesnt break them. Types of SEF support I'd like to see are: * SEF Slug additions. This is the one that usually gets used. The a search engine friendly slug is appended to the URL. i.e. /controller/view/1/my-content-title * SEF Slug replacements. This is were the id gets replaced with a SEF slug. i.e. /controller/view/my-content-title maps to /controller/view/1 * Virtual Paths. This is where a controller/action/id gets mapped to a virtual path. Probably the trickiest to do, and perhaps well beyond the scope of supporting in Cake Core. The path would be mapped to a controller/action/id on the way in, and links would be recognised and converted on the way out. * Naming of helpers. Often, I need to overload the Form or HTML helper with custom actions, or additional actions. When I do this, I have a CustomFormHelper that extends the default FormHelper, but I then have to reference the newer helper via $customForm. Given that I'm extending FormHelper, and still have access to all of those functions provided to it, I'd like to specify that $form references CustomFormHelper. Downside of this is that the programmer becomes partially responsible for resolving for variable conflicts if they incorrectly name something, or have a helper in the app controller that conflicts with a helper name in the actual controller. On Fri, May 8, 2009 at 8:29 AM, Nate nate.ab...@gmail.com wrote: Well, maybe hate's a strong word. Let's say, what do you like the least? Kind of an odd question, I know, but since we've kick-started development of a new version, I'd like to know what the most frustrating things with the framework are, even if they're things we can't fix right away. I'll get us started: PHP 4 support. Who's next? TIA for the input. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Immutable params in Dispatcher::_invoke()
Hi all I was wanting to know if it is by design that the $params argument is immutable in Dispatcher::_invoke()? I'm working on a SEF solution where I'd like to do the slug translation in the beforeFilter of my App Controller, and then set $this-params['pass'][0] to be the id of my translated slug. However, because _invoke is defined as _invoke($controller, $params), any changes in beforeFilter to $this-params never make it back into _invoke to be passed to $controller-dispatchMethod(); By changing the _invoke to be _invoke(controller, $params), I can play with param values in the beforeFilter, and have them passed through to the action. Looking at the assignment of the Dispatcher param to the controller in Dispatcher::dispatch() (Line 169: dispatcher.php for Cake 1.2.2.8120 : $controller-params = $this-params;), it looks as though there might have been an original intention to have any changed params in the controller reflected through to the dispatcher version, and vis versa. Just wondering if anyone has any informed feedback on this, and if it would be worth putting a Trac ticket through for it. The downside of the current method is that I have to resolve the slug twice. Once for the beforeFilter of the App Controller, and again on the actual action being called. Regards Reuben Helms --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---