![]() User-friendly Tool: It is helpful to create a complex web application directly.Testing: Run the base URL at the browser, products list would displayed.ĬakePHP has several features that make it highly recommended as a framework for quick and risk-free implementation of applications. If you want to load the different view for this action, you need to pass the view file name after the action element. Go to the line no.27 and change controller name from “pages” to “products” and action name from “display” to “index”. Routes: Open the app/Config/routes.php file and set the default controller and action. ![]() Model: Model creation is not required until you need validation or associations. So, the complete path of the view file ( index.ctp) would be app/View/Products/index.ctp. For creating the index view, we need to Products/ directory and a index.ctp file. The controller class name is ProductsController and method is index. View: Create view for display products in app/View/ directory. ![]() Product->find('all',array('fields'=>array('Product.id','Product.title','scription','Product.price','Product.created','Product.status'),'conditions'=>array('Product.status'=>1))) Controller file and class name should be ProductsController. Once table creation is completed, insert some demo product data into this table.Ĭontroller: Create a products controller with ProductsController class into the app/Controller/ directory. ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci `status` tinyint(1) NOT NULL DEFAULT '1', `description` text COLLATE utf8_unicode_ci NOT NULL, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, Table Creation & Data Insert: Following SQL is used for products table creation. We will fetch and display products in our sample CakePHP project. And we will insert some data manually at this table. In this sample project we will create a products table at the cakephp_db database. ![]() The basic pattern is app/View/Controller/underscored_function_name.ctp The postDetails() function of PostController class will look for a view template in app/View/Post/post_details.ctp. View Conventions – View template files are named after the controller functions they displayed, in an underscored form.Database Conventions – Table names corresponding to CakePHP models are plural and underscored.Model Conventions – Model class names are singular and CamelCased.( Post, LatestPost).Controller Conventions – Controller class names are plural, CamelCased and end in Controller.( PostsController, LatestPostsController).Step7: Run the project URL( at the browser.Go to the line no.67 and replace the values of host, login, password, database_name with your database host, database username, database password and database name.Step6: Open the “app/Config/database.php” file and make the following changes.Step5: Rename file to database.php at the app/Config/ directory.Change the value of Security.salt at Line no.225.Ĭonfigure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') Ĭonfigure::write('Security.salt', 'codexworld').Step4: Open the app/Config/core.php file and make the following changes.Step3: Create database at the phpMyAdmin.Your directory setup looks like the following. Step2: Move the cakephp/ folder to the localhost server.Step1: Extract zip file and change folder name with your desire project name.At first you need to download the stable release of CakePHP from Github – CakePHP Releases Basic Configuration ![]()
0 Comments
Leave a Reply. |