Online Forum To Support Coders With Technical Assistance - Read Write Execute

How to create profile url (http://sitename/username/) in cakephp

Ankit Agrawal
Ankit Agrawal
Published on September 21, 2015 · 1 min read

(1)Create a profile controller app/Controller/ProfileController.php and write following code

<?php
App::uses('AppController', 'Controller');

class ProfileController extends AppController {


	public function index() {
		
		 $username = $this->params['username']; 
	 
		 
	}
}
?>

(2)create a view file app/View/profile/index.ctp

(3)Open file app/Config/routes.php and add following line

<?php
	Router::connect('/:username', array('controller' => 'profile', 'action'=> 'index')); 
?>
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article How to send email in cakephp ? Next Article → How to add google recaptcha on login form in cakephp