Username Should Not Match Any Controllers And Actions Name


I want to have user view page for my website with a very simple URL, eg,

Can anyone suggest me the condition that I should use in User model to check whether user name is matching any controller’s name or action’s name?

And will there any other thing to keep in mind while implementing this?

something like this?

$list = [];

foreach (new DirectoryIterator(Yii::getPathOfAlias('application.controllers')) as $fi) {

	if($fi->isDot()) {



	$class = null;


	if (preg_match('/^(\w+)Controller\.php$/', $fi->getFilename(), $m)) {

		$class = @$m[1]; //purified controller name


		// methods

		require_once $fi->getPathname();


		if (preg_match_all('/action(\w+)/i', implode(',', get_class_methods($class.'Controller')), $m2) > 0

			&& !empty($m2[1])) {

			$list[$class] = $m2[1]; //purified methods for purified class

		} else {

			$list[$class] = [];





no sure about modules i don’t know Yii well enough yet