cakephp

Fat models, skinny controllers and the MVC design pattern

I just read a [blog post][1] that explains MVC with a banking analogy. I have a few months of experience with web application development with an MVC framework (CakePHP), so I get the basics, but I began to see a theme that made me think I'm taking a flawed approach to where I put my logic: Fat models, skinny controllers Keep as much b...

Best way to parse bbcode

I'd like to work on a bbcode filter for a php website. (I'm using cakephp, it would be a bbcode helper) I have some requirement. Bbcodes can be nested. So something like that is valid. [block] [block] [/block] [block] [block] [/block] [/block] [/block] Bbcodes can have 0 or more paramet...

CakePHP XML loading

Hey all, I am using the CakePHP XmlHelper to parse XML files like: App::import('Xml'); $file = "my_xml_file.xml"; $parsed_xml =& new XML($file); How can I use it to load XML files from URLs like http://www.site.com/file.xml Thanks! ...

How different is CakePHP from Ruby on Rails?

I almost never hear the word CakePHP without hearing the word Rails shortly afterwards. Are these two frameworks mainly similar based on how they adhere to the MVC model or do they have other significant similarities/differences? One of the main attractions of Rails for me is how easy it is to do Ajax. Would that also be true of CakePH...

Handling URLs inside a CSS in CakePHP

Heyall, I am designing a website using CSS Files a lot, but I have several occurrences of background images, images for bullets in lists and I will probably find another need for the css url() function. But, in cake, all URL should be handled by the Route::url() function, in several ways, being most common the $html->url() But my prob...

JQuery UI and CakePHP

I'm having problem showing JQuery UI themes for my CakePHP application. I placed the theme at app/webroot/lib/jquery.ui/ . Now on my layout I imported the theme using : echo $html->css('/lib/jquery-ui/theme/ui.all'); I'm usingthe DatePicker widget. On my page, I can see that the my textbox was showing the date picker when focused, bu...

Can I stop CakePHP fetching all rows for a query?

Hi, I'm using CakePHP with $modelName->find(...) calls to select quite a number of rows (could be hundreds) Normally, in PHP/MySQL of course this wouldn't be a problem, as you fetch them in a while loop. But, CakePHP loads all rows in to an array which exhausts the memory limit. Is there a way to use the $modelName->find(...) construc...

Fix for 'return' in cakePHP to return Value from view controller funtion

Hi there I have a function inside of a view function inside of a model class in the model.php file that looks like this function sqlToUnix($date){ $YMDThenHMS = explode(" ", $date); $YMD = explode("-", $YMDThenHMS[0]); $HMS = explode(":", $YMDThenHMS[1]); $UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1], $YMD[2], $...

CakePHP vs. Codeigniter

I'm new to both platform and my main decision factor is : Which one of the two will help me create and finish my first website(s) quicker? By that I mean - Better set of helpers, responsive and friendly support from the community, easier to find snippets. Integration with jQuery, available ready themes and code samples, better document...

Images management

Im building a site were users can upload images and then "use" them. What I would like some thoughts and ideas about is how to manage temporary uploads. For example, a user uploads an image but decides not to do anything with it but just leaves the site. I have then either uploaded the file to the server or loaded it to the server memo...

Saving HABTM records when not all join table columns are foreign keys

I am trying to update tables with a has and belongs to many (HABTM) relationship. When my join table looked like this: CREATE TABLE IF NOT EXISTS `items_labels` ( `item_id` int(11) NOT NULL, `label_id` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; I use CakePHP, so I could update the tables with $this->Item->save($data) ...

How do I inplement Sub-Domains and DNS CNAMES in CakePHP?

I have been using the below code in my Bootstrap.php file in CakePHP to detect subdomains, which appears to work really well. preg_match('/^(?:www\.)?(?:(.+)\.)?(.+\..+)$/i', env('HTTP_HOST'), $matches); define('SUBDOMAIN', empty($matches[1]) ? false : $matches[1]); define('HOST', $matches[2]); define('BASE_URL', 'http://' . HOST); ...

How to debug when CakePHP Model::save() doesn't attempt an INSERT

I am having a bear of a time saving the simplest record from a model called ItemView: if($this->save($this->data)) { echo 'worked'; } else { echo 'failed'; } Where $this->data is: Array ( [ItemView] => Array ( [list_id] => 1 [user_id] => 1 ) ) And my table is: CREATE TABLE IF NOT EXI...

How do i replace the cakephp password hashing algorithm?

I have an existing database I'm trying to put a cake app on top of. The old app used crypt() in Perl to hash the passwords, I need to do the same in the PHP app. Where is the correct place to make that change in a standard cakephp app? And what would such a change look like? ...

generate scaffolding as code in cakephp

I have a cakephp app with some controllers using scaffolding for the logic and views... How can I make cake actually generate those as files and functions in my project that I can then modify and take ownership of... It's nice to have this stuff as a starting point, but it can't be true that I need to start basically from scratch if I ...

How to update a <div> with jQuery and CakePHP?

I'm using CakePHP for a small web app and on one form page there's a dropdown to select a job number. I'd like to update two text fields based on the job number selected in the dropdown using jQuery (I'm also open to using the default ajax helper but I didn't have a lot of success with it). Here's my jQuery snippet: <script> $(doc...

How do you set up cakephp on a shared hosting?

This is one thing I haven't been able to do with Cake. I have tried it a few times and couldn't figure it out. I am on hostgator and it could help if someone could point how they've been setting it up (Advanced installation). Edit I have read the documentation and I get errors. I guess I haven't been reading it all too well. Edit I ju...

Qcodo vs. CakePHP vs. Zend

I have some exposure to CakePHP and think it is a great framework. Then, I run into this thing called Qcodo. It is another PHP Framework. I've been hearing Zend alot. They all seem very neat, but I'm wondering what are differences between all these frameworks. Before I waste too much time learning another framework, does anyone know p...

Custom mod rewrite in CakePHP

Hello, I've rewritten my web app using CakePHP, but now I need to have my old formatted urls redirect to my new url format. I can't seem to add my own custom mod rewrite rule. I've added it above the main cakephp rewrite rule, but I'm getting an infinite redirect loop. I just want http://mysite.com/index.php?action=showstream&amp;nicknam...

CakePHP Gurus: Console cake command not finding -app path correctly?

I've installed the CakePHP core files in this folder: /home/iopener/webapps/cake_1.2.1.8004 I've got my app installed here: /home/iopener/webapps/Smasholi.com/app The cake console command is in my path, and runs fine, but it seems to be ignoring any attempt to point it to the correct -app folder. If I run 'cake' from inside the app f...