Cake Php

JAYPEE UNIVERSITY OF ENGINEERING AND TECHNOLOGY RAGHOGARH, GUNA (M. P. ) INDUSTRIAL TRAINING REPORT at ***** Software Solutions Limited JUNE-JULY 2011 SUBMITTED BY: NAME: Rohit Gupta EN NO. : 08307G YEAR,BRANCH:2011,CSE Acknowledgement It has been a substance of gigantic inclination for me for having got an transfashion to consign my pure benediction to total populace who abandoned their costly season to acceleration me in the period of inoculation and contrivance effect. They exercise their buttress, abettance and empower me to total the contrivance effect prosperityfully. Chief I would approve to straightforward the fathomhither sensation of gratefulness to Mr. SA (Training Head) for substance a motive of poesy and providing me delay deficiencyful straightforwardion whenever I deficiencyed it, opposing his occupied catalogue. Say barely cannot straightforward the gratefulness and indebtedness to him. I would too approve to thank Mr. V&&&&&&&& who was my adviser during my aincompact at *****, who accelerationed me a lot in providing me delay media and accelerationing me in all the ways he could during the inoculation. Apostacy Sno| Topic| page| 1| Company Profile| 4| 2| Basics of PHP5| 6| 3| Basics of cake PHP| 18| 4| Implementation of Cake PHP| 44| 5| Conclusion| 50| 6| Joining voice| 51| 7| Weekly Reports| 52| | | | | | | | | | | | Company Prorasp PHP 5 Initiative Delay the apparition of PHP 5, the end mould was rewritten to apportion for reconstitute accomplishment and raise features. This was a elder substitute from PHP 4. PHP 5 has a liberal end mould. Some of the protuberant features in PHP 5, embrace are of visibility, abstract and final classes and arrangements, affixed sorcery arrangements, interfaces, cloning and imagehinting. The Basics assort Basic assort determinations originate delay the keyword class, flourished by a assort flatter, flourished by a span of curly braces which conceive the determinations of the properties and arrangements cognate to the assort. The assort flatter can be any strong delineate which is a not a PHP reserved term. A strong assort flatter set-on-foots delay a voice or adownscore, flourished by any compute of voices, mass, or adownscores. A assort may comprise its own constants, variables (designated "properties"), and sunders (designated "methods"). ------------------------------------------------- Example: Unadorned Assort determination <? php assort SimpleCdamsel { national $var = 'a default value'; national function displayVar() { reverberation $this->var; } } ?> The pseudo-variable $this is availtalented when a arrangement is planated from delayin an end tenor. this is a regard to the trade end (usually the end to which the arrangement belongs, but perluck another end, if the arrangement is planated statically from the tenor of a unimportant end). new To think an solicitation of a assort, the new keyterm must be used. Classes should be fixd anteriorly instantiation. If a string containing the flatter of a assort is used delay new, a new solicitation of that assort conquer be thinkd. If the assort is in a flatterspace, its liberaly equipd flatter must be used when doing this. ------------------------------------------------- Example: Creating an solicitation <? hp $instance = new SimpleClass(); $className = 'Foo'; $instance = new $className(); // Foo() ?> In the assort tenor, it is practictalented to think a new end by new self and new committer. When refering an alcompliant thinkd solicitation of a assort to a new capricious, the new capricious conquer admittance the selfselfresembling solicitation as the end that was refered. This behaviour is the selfselfresembling when perishing solicitations to a sunder. A portraiture of an alcompliant thinkd end can be made by cloning it. exercises A assort can occupy the arrangements and properties of another assort by using the keyword extends in the assort avowal. It is not practictalented to exercise multiple assortes; a assort can barely occupy from one dishonortalented assort. The occupyed arrangements and properties can be aggravateridden by redeclaring them delay the selfselfresembling flatter fixd in the committer assort. However, if the committer assort has fixd a arrangement as final, that arrangement may not be aggravateridden. It is practictalented to admittance the aggravateridden arrangements or static properties by referencing them delay parent::. ------------------------------------------------- Example: Unadorned Assort Hereditament <? php assort ExtendClass extends SimpleCdamsel { sunder displayVar() { reverberation "Extending class"; arent::displayVar(); } } $extended = new ExtendClass(); $extended->displayVar(); ?> ------------------------------------------------- The aggravatehead specimen conquer output: Extending assort a lapse compute Properties Assort portion capriciouss are planated "properties". They are fixd by using one of the keywords public, protected, or private, flourished by a ordinary capricious avowal. This avowal may embrace an primalization, but this primalization must be a fixed compute--that is, it must be talented to be evaluated at put-together season and must not halt on run-season counsel in dispose to be evaluated. Within assort arrangements the properties, fixeds, and arrangements may be admittanceed by using the constitute $this->property (where property is the flatter of the peculiarity) courteous-mannered-balancedtual the admittance is to a static peculiarity delayin the tenor of a static assort arrangement, in which occurrence it is admittanceed using the constituteself::$property. The pseudo-variable $this is availtalented amid any assort arrangement when that arrangement is planated from delayin an end tenor. $this is a regard to the trade end (usually the end to which the arrangement belongs, but perluck another end, if the arrangement is planated statically from the tenor of a unimportant end). Cdamsel Constants It is practictalented to fix fixed computes on a per-assort account fostering the selfselfresembling and immovable. Constants dissent from ordinary capriciouss in that you don't use the $ symbol to defend or use them. The compute must be a fixed straightforwardion, not (for specimen) a capricious, a peculiarity, a harvest of a sober influence, or a sadown flatter. ------------------------------------------------- Example: Defining and using a fixed <? php assort MyCdamsel { const constant = 'constant value'; sunder showConstant() { reverberation  self::constant . ""; } } reverberation MyClass::constant . "; $classname = "MyClass"; reverberation $classname::constant . ""; $class = new MyClass(); $class-;showConstant(); reverberation $class::constant. ""; ?; Autoloading Classes Multifarious developers adaptation end-oriented collisions think one PHP motive rasp per-assort determination. One of the biggest annoyances is having to transcribe a desire catalogue of deficiencyed embraces at the originatening of each script (one for each assort). In PHP 5, this is no desireer deficiencyful. You may fix an __autoentrust sadown which is automatically planated in occurrence you are enigmatical to use a assort/interface which hasn't been fixd yet. By trade this sadown the scripting engine is consecrated a conclusive luck to entrust the assort anteriorly PHP fails delay an blunder. ------------------------------------------------- Example: Autoentrust specimen ------------------------------------------------- This specimen attempts to entrust the assortes MyClass1 and MyClass2 from the rasps MyClass1. php and MyClass2. php respectively. <? php sunder __autoload($class_name) { embrace $class_name . '. php'; } $obj  = new MyClass1(); $obj2 = new MyClass2(); ?> Constructors and Destructors Committer void __construct ([ mixed $args [, $... ]] ) PHP 5 apportions developers to defend committer arrangements for assortes. Classes which enjoy a committer arrangement flatter this arrangement on each newly-created end, so it is suittalented for any primalization that the end may deficiency anteriorly it is used. Destructor void __destruct ( void ) PHP 5 introduces a destructor concept homogeneous to that of other end-oriented languages, such as C++. The destructor arrangement conquer be planated as promptly as all regards to a feature end are removed or when the end is lucidly destroyed or in any dispose in shutdown consequence. Approve committers, committer destructors conquer not be planated implicitly by the engine. In dispose to run a committer destructor, one would enjoy to lucidly flatter committer::__destruct() in the destructor collection. The destructor conquer be planated courteous-mannered-balanced if script deterrent is stopped using exit(). Calling exit() in a destructor conquer frustrate the fostering shutdown routines from executing. Regrant The regrant of a peculiarity or arrangement can be fixd by prefixing the avowal delay the keywords public, protected or private. Assort portions defendd national can be admittanceed allwhere. Members defendd guarded can be admittanceed barely delayin the assort itself and by occupyed and committer assortes. Members defendd as peculiar may barely be admittanceed by the assort that fixs the portion. Peculiarity Regrant Assort properties must be fixd as national, peculiar, or guarded. If defendd using var, the peculiarity conquer be fixd as national. Arrangement Regrant Assort arrangements may be fixd as national, peculiar, or guarded. Methods defendd delayout any uninterrupted regrant keyterm are fixd as national. Regrant from other ends Objects of the selfselfresembling image conquer enjoy admittance to each others peculiar and guarded portions courteous-mannered-balanced though they are not the selfselfresembling solicitations. This is owing the toolation peculiar details are alcompliant social when amid those ends. End Hereditament Inheritance is a courteous-mannered-established programming energy, and PHP establishs use of this energy in its end mould. This energy conquer favor the way multifarious assortes and ends recite to one another. For specimen, when you exercise a assort, the subassort occupys all of the national and guarded arrangements from the committer assort. Eventual a assort aggravaterides those arrangements, they conquer restrain their pristine sunderality. This is servicecogent for defining and constitutelessing sunderality, and permits the toolation of affixed sunderality in homogeneous ends delayout the deficiency to retool all of the divided sunderality. ------------------------------------------------- Specimen #1 Hereditament Specimen <? php assort foo { national function printItem($string) { reverberation 'Foo: ' . $string . PHP_EOL; } national function printPHP() { reverberation 'PHP is great. ' . PHP_EOL; } } assort bar extends foo { national function printItem($string) { reverberation 'Bar: ' . $string . PHP_EOL; } } $foo = new foo(); $bar = new bar(); foo->printItem('baz'); // Output: 'Foo: baz' $foo->printPHP();       // Output: 'PHP is great'  $bar->printItem('baz'); // Output: 'Bar: baz' $bar->printPHP();       // Output: 'PHP is great' ?> Occasion Redisruption Operator (::) The Occasion Redisruption Operator or in unadornedr provisions, the double colon, is a symbol that apportions admittance to static, fixed, and aggravateridden properties or arrangements of a assort. When referencing these items from extraneously the assort determination, use the flatter of the assort. When an exerciseing assort aggravaterides the committers determination of a arrangement, PHP conquer not flatter the committer's arrangement. It's up to the exerciseed assort on whether or not the committer's arrangement is planated. This too applies to Constructors and Destructors, Overloading, and Magic arrangement determinations. Static Keyterm Declaring assort properties or arrangements as static establishs them admittanceible delayout deficiencying an instantiation of the assort. A peculiarity defendd as static can not be admittanceed delay an instantiated assort end (though a static arrangement can). Owing static arrangements are flattertalented delayout an solicitation of the end thinkd, the pseudo-variable $this is not availtalented amid the arrangement defendd as static. Static properties cannot be admittanceed through the end using the arrow operator -;. Assort Abstrexercise PHP 5 introduces constitutehither assortes and arrangements. Classes fixd as constitutehither may not be instantiated, and any assort that comprises at lowest one constitutehither arrangement must too be constituteless. Methods fixd as constitutehither barely defend the arrangement's verification - they cannot fix the toolation. When occupying from an constitutehither assort, all arrangements noconsideration constitutehither in the committer's assort avowal must be fixd by the slip; affixedly, these arrangements must be fixd delay the selfselfresembling (or a hither odious) visibility. For specimen, if the constitutehither arrangement is fixd as guarded, the sadown toolation must be fixd as either guarded or national, but not peculiar. End Interfaces End interfaces apportion you to think legislation which specifies which arrangements a assort must tool, delayout having to fix how these arrangements are discussd. Interfaces are fixd using the interface keyword, in the selfselfresembling way as a rule assort, but delayout any of the arrangements having their divergency fixd. All arrangements defendd in an interface must be national, this is the essence of an interface. tools To tool an interface, the implements operator is used. All arrangements in the interface must be tooled delayin a assort; deficiency to do so conquer harvest in a destructive blunder. Classes may tool raise than one interface if desired by separating each interface delay a comma. Constants Its practictalented for interfaces to enjoy fixeds. Interface fixeds effects correspondently approve assort fixeds except they cannot be aggravateridden by a assort/interface that occupys it. Overloading Overloading in PHP arranges media to dynamically "create" properties and arrangements. These dynamic entities are processed via sorcery arrangements one can demonstrate in a assort for sundry exercise images. The aggravateloading arrangements are invoked when interacting delay properties or arrangements that enjoy not been defendd or are not visible in the exoteric occasion All aggravateloading arrangements must be fixd as public. PHP's exposition of "overloading" is dissentent than most end oriented languages. Overloading traditionally arranges the force to enjoy multiple arrangements delay the selfselfresembling flatter but dissentent quantities and images of disputes. Peculiarity aggravateloading __set() is run when adaptation axioms to inundetermined properties. __get() is localized for lection axioms from inundetermined properties. _isset() is triggered by trade isset() or empty() on inundetermined properties. __unset() is invoked when unset() is used on inundetermined properties. Arrangement aggravateloading modified __call ( string $name , array $arguments ) modified __callStatic ( string $name , array $arguments ) __call() is triggered when invoking inundetermined arrangements in an end tenor. __callStatic() is triggered when invoking inundetermined arrangements in a static tenor. Patterns Patterns are ways to narrate best practices and cheerful plans. They pretext a elastic disruption to contemptible programming problems. Factory The Factory sample apportions for the instantiation of ends at runtime. It is planated a Factory Sample gone it is legal for "manufacturing" an end. A Parameterized Factory receives the flatter of the assort to instantiate as dispute. ------------------------------------------------- Example: Parameterized Factory Arrangement <? php assort Example { // The parameterized factory arrangement national static function factory($type) { if (include_once 'Drivers/' . $type . '. php') {             $classname = 'Driver_' . $type; yield new $classname; } else { throw new Exception('Driver not found');         } } } ?> ------------------------------------------------ Defining this arrangement in a assort apportions drivers to be entrusted on the fly. If the Example assort was a axiomsdishonortalented constitutelession assort, entrusting a MySQLand SQLite driver could be produced as flourishs: <? php // Load a MySQL Driver $mysql = Example::factory('MySQL'); // Load an SQLite Driver $sqlite = Example::factory('SQLite'); ?> Singleton The Singleton ensures that tnear can be barely one solicitation of a Assort and arranges a global admittance purpose to that solicitation The Singleton sample is frequently tooled in Datadishonortalented Classes, Loggers, Front Controllers or Solicit and Response ends. Magic Methods The sadown flatters __construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __toString, __invoke,__set_state and __clone are sorceryal in PHP assortes. You cannot enjoy sunders delay these flatters in any of your assortes courteous-mannered-balancedtual you shortness the sorcery sunderality associated delay them. __sleep and __wakeup serialize() checks if your assort has a sadown delay the sorcery flatter __sleep. If so, that sadown is produced preceding to any serialization. It can pure up the end and is deemed to yield an arrange delay the flatters of all capriciouss of that end that should be serialized. If the arrangement doesn't yield allthing then NULL is serialized and E_NOTICE is shafterityd. __toString The __toString arrangement apportions a assort to run how it conquer recoil when it is treated approve a string. For specimen, what reverberation $obj; conquer sculpture. This arrangement must yield a string, as divergently a destructive E_RECOVERABLE_ERROR equalize bladown is emitted. __invoke The __invoke arrangement is planated when a script tries to flatter an end as a sunder. __set_enumerate The barely parameter of this arrangement is an arrange compriseing indigenous properties in the constitute array('property' =; compute, ... ). Definite Keyword PHP 5 introduces the definite keyword, which frustrates slip assortes from aggravateriding a arrangement by prefixing the determination delay definite. If the assort itself is substance fixd definite then it cannot be exerciseed. End Cloning Creating a portraiture of an end delay liberaly invertd properties is not constantly the shortnessed bearing. A cheerful specimen of the deficiency for portraiture committers, is if your end arrests a regard to another end which it uses and when you invert the committer end you shortness to think a new solicitation of this other end so that the replica has its own disconnected portraiture. An end portraiture is thinkd by using the clone keyterm (which flatters the end's __clone() arrangement if practicable). An end's __clone() arrangement cannot be planated straightway. ------------------------------------------------- $copy_of_end = clone $object; When an end is cloned, PHP 5 conquer act a shapportion portraiture of all of the end's properties. Any properties that are regards to other capriciouss, conquer halt regards. Uninterruptedly the cloning is total, if a __clone() arrangement is fixd, then the newly thinkd end's __clone() arrangement conquer be planated, o apportion any deficiencyful properties that deficiency to be substituted. Image Hinting PHP 5 introduces Image Hinting. Functions are now talented to soundness parameters to be ends (by individualizeing the flatter of the assort in the sadown prototype) or arranges (gone PHP 5. 1). However, if NULL is used as the lapse parameter compute, it conquer be apportioned as an dispute for any shafterior flatter. Objects and regards One of the key-points of PHP5 OOP that is frequently mentioned is that "objects are byed by regards by lapse". This is not totally penny. This exception rectifies that public reasoning using some specimens. A PHP regard is an alias, which apportions two dissentent capriciouss to transcribe to the selfselfresembling compute. As of PHP5, an end capricious doesn't comprise the end itself as compute anymore. It barely comprises an end identifier which apportions end admittanceors to meet the explicit end. When an end is sent by dispute, yielded or refered to another capricious, the dissentent capriciouss are not aliases: they arrest a portraiture of the identifier, which purposes to the selfselfresembling end. Cake PHP CakePHP is a free, open-source, speedy harvest framework for PHP. It’s a baseational fabric for programmers to think web collisions. The chief intent of using cake PHP is to empower us to effect in a fabricd and speedy manner–externally dropping of flexibility. CakePHP uses the correspondingness out of web harvest. It arranges us delay all the tools one deficiencys to get established coding. Instead of reinventing the trundle-wconcede all season one sits down to a new contrivance, CakePHP accelerations establish the harvest very unconcerned and speedy and raise modularized. CakePHP has an erratic developer team and nationality, bringing gigantic compute to the contrivance. Understanding Model-View-Controller CakePHP flourishs the MVC software plan sample. Programming using MVC disconnecteds your collision into three deep sunders: The Mould enacts the collision axioms The Conception furnish-up-apportions a grant of mould axioms The Manager discusss and routes solicits made by the client A Basic MVC Solicit Figure: 1 pretexts an specimen of a bare-bones MVC solicit in CakePHP. To effect-clear, seek a client lawful clicked on the “Buy A Custom Cake Now! ” join on your collision’s settlement page. Client clicks the join purposeing to http://www. specimen. com/cakes/buy, and his browser establishs a solicit to your web accommodater. The dispatcher cohibits the solicit URL (/cakes/buy), and hands the solicit to the reconstitute discussr. The discussr acts collision peculiar logic. For specimen, it may cohibit to see if Client has logged in. The discussr too uses moulds to establish admittance to the collision’s axioms. Models usually enact axiomsdishonortalented inferations, but they could too enact LDAP entries, RSS feeds, or rasps on the arrangement. In this specimen, the discussr uses a mould to procure Client’s conclusive purchases from the axiomsbase. Uninterruptedly the discussr has effected its sorcery on the axioms, it hands it to a conception. The conception uses this axioms and gets it compliant for grant to the client. Views in CakePHP are usually in HTML constituteat, but a conception could lawful as largely be a PDF, XML instrument, or JSON end halting on your deficiencys. Uninterruptedly the conception has used the axioms from the discussr to plant a liberaly furnish-up-apportioned conception, the gratified of that conception is yielded to Client’s browser. Almost all solicit to your collision conquer flourish this basic sample. We'll add some details shafterior on which are peculiar to CakePHP, so binder this in desire as we repays. Benefits Why use MVC? Bemotive it is a balmy and penny software plan sample that transforms an collision into a deeptainable, modular, speedyly open load. Crafting collision tasks into disconnected moulds, conceptions, and discussrs establishs your collision very incompact on its feet. New features are largely visible, and new faces on old features are a chip. The modular and disconnected plan too apportions developers and planers to effect coincidently, including the force to speedyly prototype. Separation too apportions developers to establish substitutes in one sadown of the collision delayout favoring others. Basic energys of Cake PHP The CakePHP frameeffect arranges a cogent-bodied dishonortalented for our collision. It can discuss all side, from the user’s primal solicit all the way to the definite account of a web page. And gone the frameeffect flourishs the energys of MVC, it apportions us to largely customize and exercise most sides of your collision. The frameeffect too arranges a basic organizational fabric, from raspnames to axiomsdishonortalented ttalented flatters, bindering your total collision accordant and close. This concept is unadorned but strong. Cake PHP fabric CakePHP features Controller, Model, and Conception assortes, but it too features some affixed assortes and ends that establish harvest in MVC a dirty hastyer and raise enjoyable. Components, Behaviors, and Helpers are assortes that arrange extensibility and reusforce to straightly add sunderality to the dishonortalented MVC assortes in your collisions. Controllers Extensions(Components) A Ingredient is a assort that aids in discussr logic. If you enjoy some logic you shortness to divide floating discussrs (or collisions), a ingredient is usually a cheerful fit. As an specimen, the kernel EmailComponent assort establishs creating and despatching emails a chip. Rather than adaptation a discussr arrangement in a unmarried discussr that acts this logic, you can load the logic so it can be divided. Controllers are too equipd delay flatterbacks. These flatterbacks are availtalented for your use, lawful in occurrence you deficiency to extort some logic floating CakePHP’s kernel influences. Callbacks availtalented embrace: * anteriorlyFilter(), produced anteriorly any discussr exercise logic * anteriorlyRender(), produced succeeding discussr logic, but anteriorly the conception is furnish-up-apportioned * succeedingFilter(), produced succeeding all discussr logic, including the conception furnish-up-apportion. Tnear may be no dissentence floating succeedingRender() and succeedingFilter() courteous-mannered-balancedtual you’ve manually made a flatter to furnish-up-apportion() in your discussr exercise and enjoy embraced some logic succeeding that flatter. Conception Extensions (Helpers) Helper is a assort that aids in conception logic. Much approve a ingredient used floating discussrs, accelerationers apportion grantal logic to be admittanceed and divided floating conceptions. Most collisions enjoy pieces of conception legislation that are used frequently. CakePHP facilitates conception legislation reuse delay layouts and components. By lapse, all conception furnish-up-apportioned by a discussr is referd amid a layout. Elements are used when fine snippets of gratified deficiency to be reused in multiple conceptions. Mould Extensions (“Behaviors”) Homogeneous to Components and Helpers, "Behaviors" effect as ways to add contemptible sunderality floating moulds. For specimen, if you refer-of-occupation user axioms in a tree fabric, you can individualize your "User" mould as behaving approve a tree, and establish clear sunderality for removing, adding, and modification nodes in your adownlying tree fabric. Models too are buttressed by another assort planated a DataSource. DataSources are an constitutelession that empower moulds to discuss dissentent images of axioms accordantly. While the deep motive of axioms in a CakePHP collision is frequently a axiomsbase, you authority transcribe affixed DataSources that apportion your moulds to enact RSS feeds, CSV rasps, LDAP entries, or iCal courteous-mannered-balancedts. Lawful approve discussrs, moulds are featured delay flatterbacks as courteous-mannered. A Typical CakePHP Solicit let’s think that our client lawful clicked on the “Buy A Custom Cake Now! ” join on a CakePHP collision’s landing page. Typical Cake Request. 1. Client clicks the join purposeing to http://www. specimen. com/cakes/buy, and his browser establishs a solicit to your web accommodater. . The Router parses the URL in dispose to cite the parameters for this solicit: the discussr, exercise, and any other disputes that conquer favor the occupation logic during this solicit. 3. Using routes, a solicit URL is mapped to a discussr exercise (a arrangement in a peculiar discussr assort). In this occurrence, it’s the buy() arrangement of the CakesController. The discussr’s anteriorlyFilter() flattertail is planated anteriorly any discussr exercise logic is produced. 4. The discussr may use moulds to establish admittance to the collision’s axioms. In this specimen, the discussr uses a mould to procure Client’s conclusive purchases from the axiomsbase. Any applictalented mould flatterbacks, bearings, and DataSources may exercise during this influence. Occasion mould achieveance is not insist-upond, all CakePHP discussrs primally insist-upon at lowest one mould. 5. Succeeding the mould has repaird the axioms, it is yielded to the discussr. Mould flatterbacks may exercise. 6. The discussr may use ingredients to raise produce-glossy the axioms or act other influences (gathering molding, verification, or despatching emails, for specimen). 7. Once the discussr has used moulds and ingredients to equip the axioms sufficiently, that axioms is handed to the conception using the discussr’s set() arrangement. Manager flatterbacks may be applied anteriorly the axioms is sent. The conception logic is acted, which may embrace the use of components and/or accelerationers. By lapse, the conception is furnish-up-apportioned amid of a layout. 8. Affixed discussr flatterbacks (approve succeedingFilter) may be applied. The total, furnish-up-apportioned conception legislation is sent to Client’s browser. CakePHP Folder Fabric Succeeding downloading and citeed CakePHP, these are the rasps and folders one should see: * app cake * vendors * plugins * . htadmittance * apostacy. php * README Three deep folders are: * The app folder conquer be wnear you effect your sorcery: it’s wnear your collision’s rasps conquer be referd. * The cake folder is wnear we’ve effected our sorcery. Establish a disunited commitment not to edit rasps in this folder. We can’t acceleration you if you’ve qualified the kernel. * Finally, the vendors folder is wnear you’ll refer third-policy PHP libraries you deficiency to use delay your CakePHP collisions. The App Folder CakePHP’s app folder is wnear you conquer do most of your collision harvest. Let’s seem a dirty closer at the folders amid of app. config| Holds the (few) delineation rasps CakePHP uses. Datadishonortalented union details, bootstrapping, kernel delineation rasps and raise should be refer-of-businessd near. | discussrs| Contains your collision’s discussrs and their ingredients. | Libs| Contains 1st sundery libraries that do not behind from 3rd sunderies or visible vendors. This apportions you to disconnected your organization's interior libraries from vendor libraries. | locale| Stores string rasps for internationalization. | moulds| Contains your collision’s moulds, bearings, and axiomssources. plugins| Contains plugin loads. | tmp| This is wnear CakePHP refer-of-businesss limited axioms. The explicit axioms it refer-of-businesss halts on how you enjoy CakePHP ford, but this folder is usually used to refer-of-occupation mould descriptions, logs, and rarely gathering counsel. Establish enduring that this folder halts and that it is writable, divergently the accomplishment of your collision conquer be severely impacted. In debug legislation, CakePHP conquer dissuade you if it is not the occurrence. | vendors| Any third-policy assortes or libraries should be referd near. Doing so establishs them unconcerned to admittance using the App::import('vendor', 'name') sunder. Keen observers conquer voice that this seems unnecessary, as tnear is too a vendors folder at the top correspondentize of our straightforwardory fabric. We'll get into the dissentences floating the two when we examine managing multiple collisions and raise compound arrangement setups. | conceptions| Presentational rasps are referd near: components, bladown pages, accelerationers, layouts, and conception rasps. | webroot| In a evolution setup, this folder should accommodate as the instrument commencement for your collision. Folders near too accommodate as arresting refers for CSS stylesheets, images, and JavaScript rasps| CakePHP Conventions CakePHP’s conventions enjoy been distilled out of years of web harvest proof and best practices. CakePHP Conventions Rasp and Classflatter Conventions In public, raspnames are adownscored occasion assortnames are CamelCased. So if you enjoy a assort MyNiftyClass, then in Cake, the rasp should be flatterd my_nifty_class. php. Adown are specimens of how to flatter the rasp for each of the dissentent images of assortes you would typically use in a CakePHP collision: Each rasp would be located in or adown (can be in a subfolder) the embezzle folder in your app folder. Mould and Datadishonortalented Conventions Model assortnames are consummate and CamelCased. Person, BigPerson, and ReallyBigPerson are all specimens of customary mould flatters. Ttalented flatters resembling to CakePHP moulds are plural and adownscored. The adownlying inferations for the aggravatehead mentioned moulds would be populace, big_people, and really_big_people, respectively. Ground flatters delay two or raise provisions are adownscored approve, chief_name. Manager Convention Manager assortnames are plural, CamelCased, and end in Controller. PeopleController and LatestArticlesController are twain specimens of customary discussr flatters. Conception Conventions View template rasps are flatterd succeeding the discussr sunders they ostentation, in an adownscored constitute. The getReady() sadown of the PeopleController assort conquer seem for a conception template in /app/views/people/get_ready. ctp. Developing delay CakePHP Installation Installing CakePHP can be as unadorned as slapping it in your web accommodater’s instrument commencement, or as compound and elastic as you craving. Tnear are three deep establishation images for CakePHP: harvest, evolution, and tardy. * Development: unconcerned to get going, URLs for the collision embrace the CakePHP establishation straightforwardory flatter, and hither assure. Production: Requires the force to for the web accommodater’s instrument commencement, pure URLs, very assure. * Advanced: Delay some delineation, apportions you to refer key CakePHP straightforwardories in dissentent sunders of the raspsystem, perluck sharing a unmarried CakePHP kernel library folder floatingst multifarious CakePHP collisions. Harvest A harvest establishation is the fastest arrangement to setup Cake. This specimen conquer acceleration you establish a CakePHP collision and establish it availtalented at http://www. specimen. com/cake_1_3/. We seek for the purposes of this specimen that your instrument commencement is set to /var/www/html. Unpack the divergency of the Cake archive into /var/www/html. You now enjoy a folder in your instrument commencement flatterd succeeding the acquit you've downloaded (e. g. cake_1. 3. 0). Reflatter this folder to cake_1_3. Your harvest setup conquer seem approve this on the rasp arrangement: * /var/www/html * /cake_1_3 * /app * /cake * /vendors * /. htadmittance * /index. php * /README If your web accommodater is ford reformly, you should now meet your Cake collision admittanceible at http://www. specimen. com/cake_1_3/. ------------------------------------------------- Controllers Introduction A discussr is used to discuss the logic for a sadown of your collision. Most contemptiblely, discussrs are used to discuss the logic for a unmarried mould. For specimen, if you were fabric a seat for an oncontinuity bakery, you authority enjoy a RecipesController and a IngredientsController managing your directions and their ingredients. In CakePHP, discussrs are flatterd succeeding the mould they discuss, in plural constitute. Your collision's discussrs are assortes that exercise the CakePHP AppController assort, which in transfashion exercises a kernel Manager assort, which are sadown of the CakePHP library. The AppController assort can be fixd in /app/app_controller. php and it should comprise arrangements that are divided floating all of your collision’s discussrs. Controllers can embrace any compute of arrangements which are usually referred to as exercises. Actions are discussr arrangements used to ostentation conceptions. An exercise is a unmarried arrangement of a discussr. CakePHP’s dispatcher flatters exercises when an incoming solicit matches a URL to a discussr’s exercise ------------------------------------------------- The App Manager As enumerated in the initiative, the AppController assort is the committer assort to all of your collision's discussrs. AppController itself exercises the Manager assort embraced in the CakePHP kernel library. As such, AppController is fixd in /cake/libs/controller/app_controller. php or /app/app_controller. php. If /app/app_controller. php does not halt then portraiture from /cake dregs anteriorly customizing for collision. It comprises a skeleton determination: ------------------------------------------------- <? php ------------------------------------------------- assort AppController exercises Manager { ------------------------------------------------- } ------------------------------------------------- ?> 1. ------------------------------------------------ <? php 2. ------------------------------------------------- assort AppController exercises Manager { 3. ------------------------------------------------- } 4. ------------------------------------------------- ?> Manager signs and arrangements thinkd in your AppController conquer be availtalented to all of your collision's discussrs. It is the notional refer to think legislation that is contemptible to all of your discussrs. Components (which you'll gather encircling shafterior) are best used for legislation that is used in multifarious (but not necessarily all) discussrs. While ordinary end-oriented occupyance rules exercise, CakePHP too does a bit of extra effect when it behinds to extraordinary discussr signs, approve the catalogue of ingredients or accelerationers used by a discussr. In these occurrences, AppController compute arranges are merged delay slip discussr assort arranges. ------------------------------------------------- The Pages Manager CakePHP kernel ships delay a lapse discussr planated the Pages Manager (cake/libs/controller/pages_controller. php). The settlement page you see succeeding establishation is generated using this discussr. It is publicly used to accommodate static pages. Eg. If you establish a conception rasp app/views/pages/about_us. ctp you can admittance it using url http://example. com/pages/about_us ------------------------------------------------- Manager Attributes $flatter Populace using PHP4 should set-on-foot out their discussr determinations using the $flatter sign. The $flatter sign should be set to the flatter of the discussr. Usually this is lawful the plural constitute of the chief mould the discussr uses. This uses caution of some PHP4 assortflatter oddities and accelerations CakePHP dictate naming. ------------------------------------------------- <? php ------------------------------------------------ ------------------------------------------------- # $flatter discussr sign achieveance specimen ------------------------------------------------- ------------------------------------------------- assort RecipesController exercises AppController { ------------------------------------------------- var $flatter = 'Recipes'; ------------------------------------------------- } ------------------------------------------------- ------------------------------------------------- ?> See comments for this exception $components, $helpers and $uses The next most frequently used discussr signs recount CakePHP what accelerationers, ingredients, and moulds you’ll be using in enumeration delay the exoteric discussr. Using these signs establish MVC assortes consecrated by $components and $uses availtalented to the discussr as assort capriciouss ($this-;ModelName, for specimen) and those consecrated by $helpers to the conception as an end regard capricious ($helpername). Controllers enjoy admittance to their chief mould availtalented by lapse. Our RecipesController conquer enjoy the Direction mould assort availtalented at $this-;Recipe, and our ProductsController too features the Product mould at $this-;Product. However, when apportioning a discussr to admittance affixed moulds through the $uses capricious, the flatter of the exoteric discussr's mould must too be embraced. This is effect-cleard in the specimen adown. The Html and Constitute Helpers are constantly availtalented by lapse. But if you adopt to fix your own $helpers arrange in AppController, establish enduring to embrace Html and Constitute if you shortness them stationary availtalented by lapse in your own Controllers. The Gathering Helper and Ingredient may be servicecogent to discuss gatherings and enumerate in your collision. Let’s seem at how to recount a CakePHP discussr that you plan to use affixed MVC assortes. ------------------------------------------------ <? php ------------------------------------------------- assort RecipesController exercises AppController { ------------------------------------------------- var $flatter = 'Recipes'; ------------------------------------------------- ------------------------------------------------- var $uses = arrange('Recipe', 'User'); ------------------------------------------------- var $helpers = arrange('Ajax'); ------------------------------------------------- var $components = arrange('Email'); ------------------------------------------------- } ------------------------------------------------- > See comments for this exception Page-connected Attribute: $layout A few signs halt in CakePHP discussrs that furnish you administer aggravate how your conception is set amid of a layout. The $layout sign can be set to the flatter of a layout saved in /app/views/layouts. You individualize a layout by setting $layout correspondent to the flatter of the layout rasp minus the . ctp production. If this sign has not been fixd, CakePHP furnish-up-apportions the lapse layout, lapse. ctp. If you enjoyn’t fixd one at /app/views/layouts/default. ctp, CakePHP’s kernel lapse layout conquer be furnish-up-apportioned. ------------------------------------------------- lt;? php ------------------------------------------------- ------------------------------------------------- // Using $layout to fix an hesitate layout ------------------------------------------------- ------------------------------------------------- assort RecipesController exercises AppController { ------------------------------------------------- sadown hastySave() { ------------------------------------------------- $this->layout = 'ajax'; ------------------------------------------------- } ------------------------------------------------- } ------------------------------------------------- ------------------------------------------------ ?> See comments for this exception The Parameters Sign ($params) Manager parameters are availtalented at $this->params in your CakePHP discussr. This capricious is used to arrange admittance to counsel encircling the exoteric solicit. The most contemptible achieveance of $this->params is to get admittance to counsel that has been handed to the discussr via POST or GET influences. See comments for this exception constitute: $this->params['form'] Any POST axioms from any constitute is refer-of-businessd near, including counsel too base in $_FILES. See comments for this exception admin: $this->params['admin'] Is set to 1 if the exoteric exercise was invoked via admin routing. See comments for this exception bare: $this->params['bare'] Stores 1 if the exoteric layout is leisure, 0 if not. See comments for this exception isAjax: $this->params['isAjax'] Stores 1 if the exoteric solicit is an ajax flatter, 0 if not. This capricious is barely set if the RequestHandler Ingredient is substance used in the discussr. See comments for this exception discussr: $this->params['controller'] Stores the flatter of the exoteric discussr handling the solicit. For specimen, if the URL /posts/view/1 was solicited, $this->params['controller'] would correspondent "posts". See comments for this exception exercise: $this->params['action'] Stores the flatter of the exoteric exercise handling the solicit. For specimen, if the URL /posts/view/1 was solicited, $this->params['action'] would correspondent "view". See comments for this exception by: $this->params['pass'] Produce an arrange (numerically apostacyed) of URL parameters succeeding the Action. See comments for this exception url: $this->params['url'] Stores the exoteric URL solicited, adesire delay key-compute spans of get capriciouss. For specimen, if the URL /posts/view/? var1=3&var2=4 was planated, $this->params['url'] would comprise: See comments for this exception ata: $this->axioms Used to discuss POST axioms sent from the FormHelper constitutes to the discussr. ------------------------------------------------- // The FormHelper is used to think a constitute component: ------------------------------------------------- reverberation $this->Form->text('User. chief_name'); See comments for this exception flatterd $this->params['named'] Stores any flatterd parameters in the url interrogation string in the constitute /key:value/. For specimen, if the URL /posts/view/var1:3/var2:4 was solicited, $this->params['named'] would be an arrange compriseing: See comments for this exception ------------------------------------------------ Manager Methods .Interacting delay Views Controllers interact delay the conception in a compute of ways. Chief they are talented to by axioms to the conceptions, using set(). You can too run which conception assort to use, and which conception rasp should be furnish-up-apportioned from the discussr. See comments for this exception set: set(string $var, modified $value) The set() arrangement is the deep way to despatch axioms from your discussr to your conception. Uninterruptedly you've used set(), the capricious can be admittanceed in your conception. ------------------------------------------------- <? hp ------------------------------------------------- ------------------------------------------------- //First you by axioms from the discussr: ------------------------------------------------- ------------------------------------------------- $this->set('color', 'pink'); ------------------------------------------------- ------------------------------------------------- //Then, in the conception, you can localize the axioms: ------------------------------------------------- ?> ------------------------------------------------- ------------------------------------------------- You enjoy chosen ;? php reverberation $color; ? ; icing for the cake. The set() arrangement too uses an associative arrange as its chief parameter. This can frequently be a hasty way to refer a set of counsel to the conception. See comments for this exception furnish-up-apportion: furnish-up-apportion(string $action, string $layout, string $file) The furnish-up-apportion() arrangement is automatically planated at the end of each solicited discussr exercise. This arrangement acts all the conception logic (using the axioms you’ve consecrated in using the set() arrangement), refers the conception amid its layout and accommodates it tail to the end user. Although CakePHP conquer automatically flatter it (eventual you’ve set $this-;autoRender to spurious) succeeding all exercise’s logic, you can use it to individualize an hesitate conception rasp by individualizeing an exercise flatter in the discussr using $action. See comments for this exception Account a peculiar conception In your discussr you may shortness to furnish-up-apportion a dissentent conception than what would customaryly be produced. You can do this by trade furnish-up-apportion() straightway. Uninterruptedly you enjoy planated furnish-up-apportion() CakePHP conquer not try to re-give-up-apportion the conception. ------------------------------------------------- damsel PostsController exercises AppController { ------------------------------------------------- sadown my_action() { ------------------------------------------------- $this->render('custom_file'); ------------------------------------------------- } ------------------------------------------------- } See comments for this exception Stream Administer See comments for this exception redirect: redirect(modified $url, integer $status, boolean $exit) The stream administer arrangement you’ll use most frequently is redirect(). This arrangement uses its chief parameter in the constitute of a CakePHP-relative URL. When a user has prosperityabundantly referd an dispose, you authority craving to restraightforward them to a voucher ward. ------------------------------------------------- sadown referOrder() { ------------------------------------------------- ------------------------------------------------- //Logic for definiteizing dispose goes near ------------------------------------------------- ------------------------------------------------- if($success) { ------------------------------------------------- $this->redirect(array('controller' => 'orders', 'action' => 'thanks')); ------------------------------------------------- else { ------------------------------------------------- $this->redirect(array('controller' => 'orders', 'action' => 'confirm')); ------------------------------------------------- } ------------------------------------------------- } The cooperate parameter of redirect() apportions you to fix an HTTP setation legislation to accompany the redirect. You may shortness to use 301 (moved permanently) or 303 (see other), halting on the essence of the redirect. The arrangement conquer shafterity an departure() succeeding the restraightforward courteous-mannered-balancedtual you set the third parameter to spurious. See comments for this exception glitter lash(string $message, string $url, integer $pause, string $layout) Approve redirect(), the glitter() arrangement is used to straightforward a user to a new page succeeding an influence. The glitter() arrangement is dissentent in that it pretexts a notice anteriorly perishing the user on to another URL. The chief parameter should arrest the notice to be ostentationed, and the cooperate parameter is a CakePHP-relative URL. CakePHP conquer ostentation the $notice for $cessation cooperates anteriorly forwarding the user on. If there's a feature template you'd approve your glittered notice to use, you may individualize the flatter of that layout in the $layout parameter. See comments for this exception Callbacks CakePHP discussrs behind equipd delay flatterbacks you can use to extort logic lawful anteriorly or succeeding discussr exercises are furnish-up-apportioned. anteriorlyFilter() This sadown is produced anteriorly all exercise in the discussr. It's a accelerationful refer to cohibit for an erratic gathering or scrutinize user permissions. anteriorlyRender() Designated succeeding discussr exercise logic, but anteriorly the conception is furnish-up-apportioned. This flattertail is not used frequently, but may be deficiencyed if you are trade furnish-up-apportion() manually anteriorly the end of a consecrated exercise. succeedingFilter() Designated succeeding all discussr exercise, and succeeding account is total. This is the conclusive discussr arrangement to run. CakePHP too buttresss flatterbacks recited to scaffolding. _beforeScaffold($method) $arrangement flatter of arrangement planated specimen apostacy, edit, etc. _afterScaffoldSave($method) $arrangement flatter of arrangement planated either edit or update. See comments for this exception See comments for this exception See comments for this exception entrustModel entrustModel(string $modelClass, modified $id) The entrustModel sadown behinds accelerationful when you deficiency to use a mould which is not the discussr's lapse mould or its associated mould. ------------------------------------------------- $this->loadModel('Article'); ------------------------------------------------- recentArticles = $this->Article->find('all', arrange('limit' => 5, 'order' => 'Article. thinkd DESC')); Components Components are loads of logic that are divided floating discussrs. If you meet yourself shortnessing to portraiture and paste things floating discussrs, you authority infer wrapping some sunderality in a ingredient. CakePHP too behinds delay a fantastic set of kernel ingredients you can use to aid in: * Security * Sessions * Admittance administer catalogues * Emails * Cookies * Verification * Solicit handling Each of these kernel ingredients are inferential in their own chapters. For now, we’ll pretext you how to think your own ingredients. Creating ingredients binders discussr legislation pure and apportions you to reuse legislation floating contrivances. ------------------------------------------------- Creating Components Suppose our oncontinuity collision deficiencys to act a compound sober influence in multifarious dissentent sunders of the collision. We could think a ingredient to offspring this divided logic for use in multifarious dissentent discussrs. The chief stalk is to think a new ingredient rasp and assort. Think the rasp in /app/controllers/components/math. php. The basic fabric for the ingredient would seem star approve this: ------------------------------------------------- <? php ------------------------------------------------ ------------------------------------------------- assort MathComponent exercises End { ------------------------------------------------- sadown doComplexOperation($amount1, $amount2) { ------------------------------------------------- yield $amount1 + $amount2; ------------------------------------------------- } ------------------------------------------------- } ------------------------------------------------- ------------------------------------------------- ?> 1. ------------------------------------------------- <? php 2. ------------------------------------------------- damsel MathComponent exercises End { 3. ------------------------------------------------- sadown doComplexOperation($amount1, $amount2) { 4. ------------------------------------------------- yield $amount1 + $amount2; 5. ------------------------------------------------- } 6. ------------------------------------------------- } 7. ------------------------------------------------- ?> Including Components in your Controllers Uninterruptedly our ingredient is artistic, we can use it in the collision's discussrs by placing the ingredient's flatter (minus the "Component" sunder) in the discussr's $components arrange. The discussr conquer automatically be consecrated a new sign flatterd succeeding the ingredient, through which we can admittance an solicitation of it: ------------------------------------------------- /* Establish the new ingredient availtalented at $this->Math, ------------------------------------------------- as courteous-mannered-mannered as the rule $this->Session */ ------------------------------------------------- var $components = arrange('Math', 'Session'); 1. ------------------------------------------------- var $components = arrange('Math', 'Session'); See comments for this exception See comments for this exception Using other Components in your Component Sometimes one of your ingredients may deficiency to use another. You can embrace other ingredients in your ingredient the upright selfselfresembling way you embrace them in discussrs: Use the $components var. ------------------------------------------------- <? php ------------------------------------------------- assort CustomComponent exercises End { ------------------------------------------------- var $flatter = 'Custom'; // the flatter of your ingredient ------------------------------------------------- var $components = arrange('Existing'); // the other ingredient your ingredient uses ------------------------------------------------- ------------------------------------------------ sadown primalize(&$controller) { ------------------------------------------------- $this->Existing->foo(); ------------------------------------------------- } ------------------------------------------------- ------------------------------------------------- sadown bar() { ------------------------------------------------- // ... ------------------------------------------------- } ------------------------------------------------- } ------------------------------------------------- ?> ------------------------------------------------- Models Models enact axioms and are used in CakePHP collisions for axioms admittance. A mould usually enacts a axiomsdishonortalented ttalented but can be used to admittance allthing that refer-of-businesss axioms such as rasps, LDAP memorials, iCal courteous-mannered-balancedts, or rows in a CSV rasp. A mould can be associated delay other moulds. For specimen, a Direction may be associated delay the Author of the direction as courteous-mannered-mannered as the Ingredient in the direction. A Mould enacts your axioms mould. In end-oriented programming a axioms mould is an end that enacts a "thing", approve a car, a individual, or a offspring. A blog, for specimen, may enjoy multifarious blog shafts and each blog shaft may enjoy multifarious comments. The Blog, Post, and Comment are all specimens of moulds, each associated delay another. This included assort, AppModel, is leiunquestioning and if you enjoyn't thinkd your own is enthralled from delayin the /cake/ folder. Overriding the AppModel apportions you to fix sunderality that should be made availtalented to all moulds delayin your collision. To do so, you deficiency to think your own app_model. php rasp that resides in the commencement of the /app/ folder. Delay your mould fixd, it can be admittanceed from delayin your Controller. CakePHP conquer automatically establish the mould availtalented for admittance when its flatter matches that of the discussr. ------------------------------------------------ <? php ------------------------------------------------- assort IngredientsController exercises AppController { ------------------------------------------------- sadown apostacy() { ------------------------------------------------- //grab all ingredients and by it to the conception: ------------------------------------------------- $ingredients = $this->Ingredient->find('all'); ------------------------------------------------- $this->set('ingredients', $ingredients); ------------------------------------------------- } ------------------------------------------------- ------------------------------------------------- ------------------------------------------------- ?> ------------------------------------------------- Retrieving Your Axioms from axiomsbases Find: meet($type, $params) Meet is the multifunctional effecthorse of all mould axioms-retrieval sunders. $image can be either 'all', 'first', 'count', 'list', 'neighbors' or 'threaded'. The lapse meet image is 'first'. $params is used to by all parameters to the sundry meets, and has the flourishing practictalented keys by lapse - all of which are optional: ------------------------------------------------- rray( ------------------------------------------------- 'conditions' => arrange('Model. ground' => $thisValue), //arrange of stipulations ------------------------------------------------- 'recursive' => 1, //int ------------------------------------------------- 'fields' => arrange('Model. ground1', 'DISTINCT Model. ground2'), //arrange of ground flatters ------------------------------------------------- 'order' => arrange('Model. thinkd', 'Model. ground3 DESC'), //string or arrange defining dispose ------------------------------------------------- 'group' => arrange('Model. ield'), //fields to GROUP BY ------------------------------------------------- 'limit' => n, //int ------------------------------------------------- 'page' => n, //int ------------------------------------------------- 'offset'=>n, //int ------------------------------------------------- 'callbacks' => penny //other practictalented computes are spurious, 'before', 'after' ------------------------------------------------- ) 1. ------------------------------------------------- arrange( 2. ------------------------------------------------- 'conditions' => arrange('Model. ground' => $thisValue), //arrange of stipulations 3. ------------------------------------------------ 'recursive' => 1, //int 4. ------------------------------------------------- 'fields' => arrange('Model. ground1', 'DISTINCT Model. ground2'), //arrange of ground flatters 5. ------------------------------------------------- 'order' => arrange('Model. thinkd', 'Model. ground3 DESC'), //string or arrange defining dispose 6. ------------------------------------------------- 'group' => arrange('Model. ground'), //fields to GROUP BY 7. ------------------------------------------------- 'limit' => n, //int 8. ------------------------------------------------- page' =; n, //int 9. ------------------------------------------------- 'offset'=>n, //int 10. ------------------------------------------------- 'callbacks' => penny //other practictalented computes are spurious, 'before', 'after' 11. ------------------------------------------------- ) See comments for this exception meet('first'): meet('first', $params) 'first' is the lapse meet image, and conquer yield one harvest, you'd use this for any use wnear you anticipate barely one harvest. If no harvests are base, spurious is yielded. meet('count'): meet('count', $params) meet('count', $params) yields an integer compute. Tnear are no affixed parameters used by meet('count'). See comments for this exception meet('all'): meet('all', $params) meet('all') yields an arrange of (theoretically multiple) harvests. It is in occurrence the means used by all meet() variants, as courteous-mannered-mannered as paginate. meet('list'): meet('list', $params) meet('list', $params) yields an apostacyed arrange, servicecogent for any use wnear you would shortness a catalogue such as for populating input picked boxes. meet('threaded'): meet('threaded', $params) meet('threaded', $params) yields a nested arrange, and is embezzle if you shortness to use the committer_id ground of your mould axioms to plant nested harvests. ind('neighbors'): meet('neighbors', $params) 'neighbors' conquer act a meet homogeneous to 'first', but conquer yield the row anteriorly and succeeding the one you solicit. See comments for this exception meetBy meetBy;fieldName;(string $value); The meetBy sorcery sunders too sanction some optional parameters: meetBy;fieldName;(string $value[, modified $fields[, modified $order]]); These sorcery sunders can be used as a shortcut to inquiry your inferations by a unquestioning ground. Lawful add the flatter of the ground (in CamelCase constituteat) to the end of these sunders, and give the criteria for that ground as the chief parameter. PHP5 meetBy;x; Specimen | Resembling SQL Fragment | $this-;Product-;findByOrderStatus(‘3’); | Product. dispose_foundation = 3 | $this-;Recipe-;findByType(‘Cookie’); | Recipe. image = ‘Cookie’ | $this-;User-;findByLastName(‘Anderson’); | User. conclusive_flatter = ‘Anderson’ | $this-;Cake-;findById(7); | Cake. id = 7 | $this-;User-;findByUserName(‘psychic’); | User. user_flatter = ‘psychic’ | See comments for this exception interrogation interrogation(string $query) SQL flatters that you can't or don't shortness to establish via other mould arrangements (this should barely rarely be deficiencyful) can be made using the mould's interrogation() arrangement. See comments for this exception ground: ground(string $name, arrange $stipulations = vain, string $dispose = vain) Produce the compute of a unmarried ground, certain as $name, from the chief archives matched by $stipulations as disposeed by $order. If no stipulations are byed and the mould id is set, conquer yield the ground compute for the exoteric mould harvest. If no matching archives is base yields spurious. recognize(): recognize($fields, $id) recognize() is a arrangement used to set the exoteric mould axioms (Model::$data)--such as during edits--but it can too be used in other qualification to repair a unmarried archives from the axiomsbase. grounds is used to by a unmarried ground flatter, as a string, or an arrange of ground flatters; if left leisure, all grounds conquer be procureed. $id specifies the ID of the archives to be recognize. By lapse, the exotericly chosen archives, as certain by Model::$id, is used. Perishing a dissentent compute to $id conquer motive that archives to be chosen. ------------------------------------------------- Behaviors Mould bearings are a way to adfair some of the sunderality fixd in CakePHP moulds. They apportion us to disconnected logic that may not be straightway recited to a mould, but deficiencys to be there. By providing a unadorned yet strong way to exercise moulds, bearings apportion us to conciliate sunderality to moulds by defining a unadorned assort capricious. That's how bearings apportion moulds to get rid of all the extra burden that authority not be sadown of the occupation conceive they are moulding, or that is too deficiencyed in dissentent moulds and can then be extrapolated. As an specimen, infer a mould that furnishs us admittance to a axiomsdishonortalented ttalented which refer-of-businesss structural counsel encircling a tree. Removing, adding, and migrating nodes in the tree is not as unadorned as deleting, extorting, and editing rows in the inferation. Many memorials may deficiency to be updated as things instigate environing. Rather than creating those tree-molding arrangements on a per mould account (for all mould that deficiencys that sunderality), we could barely recount our mould to use the TreeBehavior, or in raise constituteal provisions, we recount our mould to beenjoy as a Tree. This is social as conciliateing a bearing to a mould. Delay lawful one continuity of legislation, our CakePHP mould uses on a all new set of arrangements that apportion it to interact delay the adownlying fabric. ------------------------------------------------- Views Views are the V in MVC. Views are legal for generating the peculiar output insist-upond for the solicit. Frequently this is in the constitute of HTML, XML, or JSON, but streaming rasps and creating PDF's that users can downentrust are too responsibilities of the Conception Layer. ------------------------------------------------- Conception Templates The conception flake of CakePHP is how you accost to your users. Most of the season your conceptions conquer be pretexting (X)HTML instruments to browsers, but you authority too deficiency to accommodate AMF axioms to a Glitter end, response to a heterogeneous collision via SOAP, or output a CSV rasp for a user. CakePHP conception rasps are written in uninterrupted PHP and enjoy a lapse production of . tp (CakePHP Template). These rasps comprise all the grantal logic deficiencyed to get the axioms it ordinary from the discussr in a constituteat that is compliant for the reception you’re serving to. Conception rasps are refer-of-businessd in /app/views/, in a folder flatterd succeeding the discussr that uses the rasps, and flatterd succeeding the exercise it corresponds to. For specimen, the conception rasp for the Products discussr's "view()" exercise, would ordinaryly be base in /app/views/products/view. ctp. * layouts: conception rasps that comprise grantal legislation that is base wrapping multifarious interfaces in your collision. Most conceptions are furnish-up-apportioned amid of a layout. * components: maller, reustalented bits of conception legislation. Elements are usually furnish-up-apportioned amid of conceptions. * accelerationers: these assortes encapsulate conception logic that is deficiencyed in multifarious refers in the conception flake. Floating other things, accelerationers in CakePHP can acceleration you plant constitutes, plant AJAX sunderality, paginate mould axioms, or accommodate RSS feeds. Caching Elements You can use custom of CakePHP conception caching if you give a cache parameter. If set to penny, it conquer cache for 1 day. Otherwise, you can set opinion inertness seasons. If you furnish-up-apportion the selfselfresembling component raise than uninterruptedly in a conception and enjoy caching empowerd be enduring to set the 'key' parameter to a dissentent flatter each season. This conquer frustrate each succesive flatter from aggravateadaptation the preceding component() flatter's cached harvest. E. g. ------------------------------------------------- <? php ------------------------------------------------- reverberation $this->element('helpbox', arrange('cache' => arrange('key' => 'first_use', 'time' => '+1 day'), 'var' => $var)); ------------------------------------------------- ------------------------------------------------- reverberation $this->element('helpbox', arrange('cache' => arrange('key' => 'second_use', 'time' => '+1 day'), 'var' => $differentVar)); ------------------------------------------------- > See comments for this exception Requesting Elements from a Plugin If you are using a plugin and craving to use components from delayin the plugin, lawful individualize the plugin parameter. If the conception is substance furnish-up-apportioned for a plugin discussr/action, it conquer automatically purpose to the component for the plugin. If the component doesn't halt in the p