Skip to main content

Posts

Routing maps your URL to specific controller’s action. In this section, we will see how you can implement routes, how you can pass arguments from URL to controller’s action, how you can generate URLs, and how you can redirect to a specific URL. Normally, routes are implemented in file  config/routes.php . Routing can be implemented in two ways − static method scoped route builder Here is an example presenting both the types. // Using the scoped route builder. Router::scope('/', function ($routes) { $routes->connect('/', ['controller' => 'Articles', 'action' => 'index']); }); // Using the static method. Router::connect('/', ['controller' => 'Articles', 'action' => 'index']); Both the methods will execute the index method of  ArticlesController . Out of the two methods  scoped route builder  gives better performance. Connecting Routes Router::connect()  method is used ...
Email can be configured in file  config/app.php . It is not required to define email configuration in config/app.php. Email can be used without it; just use the respective methods to set all configurations separately or load an array of configs. Configuration for Email defaults is created using  config()  and  configTransport() . Email Configuration Transport By defining transports separately from delivery profiles, you can easily re-use transport configuration across multiple profiles. You can specify multiple configurations for production, development and testing. Each transport needs a  className . Valid options are as follows − Mail  − Send using PHP mail function Smtp  − Send using SMTP Debug  − Do not send the email, just return the result You can add custom transports (or override existing transports) by adding the appropriate file to  src/Mailer/Transport .Transports should be named  YourTransport.php , where...
CakePHP comes with one configuration file by default and we can modify it according to our needs. There is one dedicated folder  “config”  for this purpose. CakePHP comes withdifferent configuration options. General Configuration The following table describes the role of various variables and how they affect your CakePHP application. S.No Variable Name & Description 1 debug Changes CakePHP debugging output. false = Production mode. No error messages, errors, or warnings shown. true = Errors and warnings shown. 2 App.namespace The namespace to find app classes under. 3 App.baseUrl Un-comment this definition if you don’t plan to use Apache’s mod_rewrite with CakePHP. Don’t forget to remove your .htaccess files too. 4 App.base The base directory the app resides in. If false, this will be auto detected. 5 App.encoding Define what encoding your application uses. This encoding is used to generate the charset in the layout, and encode entities. ...
Take a look at the following screenshot. It shows the folder structure of CakePHP. The following table describes the role of each folder − S.No Folder Name & Description 1 bin The bin folder holds the Cake console executables. 2 config The config folder holds the (few) configuration files CakePHP uses. Database connection details, bootstrapping, core configuration files and more should be stored here. 3 logs The logs folder normally contains your log files, depending on your log configuration. 4 plugins The plugins folder is where the Plugins your application uses are stored. 5 src The src folder will be where you work your magic: It is where your application’s files will be placed. CakePHP’s src folder is where you will do most of your application development. Let’s look a little closer at the folders inside src. Console Contains the console commands and console tasks for your application. Controller Contains your application’s controllers and t...