Organization Application Directory

Hi Dear,

I want to organize my application as


-App Root

-- common // For all sort of common elements of the application

---------models

---------messages

--backend

---------controllers etc

--customer

---------controllers etc

--templates

-----------backend

------------------basic

-------------------------themes

--------------------------------classic

----------customer

------------------basic

-------------------------themes

--------------------------------classic

How can I do configure it?

Done

Just Play with your main.php

and have the structure as you want.

Yii - Yes It Is Indeed

I am happy that you solved, but why not to use modules?

This will create a structure like:




protected

-- models

----backend

-------controllers

---------conteroller1

---------conteroller2

---------conteroller3

-------models

-------views


----customer

-------controllers

---------conteroller1

---------conteroller2

---------conteroller3

-------models

-------views




This structure will hold in the same directory all files related to a certain model, is supported by gii and also allows you to add rules on the whole module (for example forbid the backend module to non-admin user and so on).

PeRoChAk and zaccaria, Could you show me your config that allowes this directory settings ?

@ zaccaria

Thanks for your insight.

Actually, what I am going to develop have the features as

1 - User can select their own templates(Layouts)

2- User can select their own skins (themes)

3- System will be plugin based so that new functionality could be added with eases.

Current structure of Yii Application does not allow me to have

1 - Custom skins

3 - Custom Templates

So, I do need to have my own structure

@I.N.Sobolev

I will share it

Here is my Configuration file




<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'/protected/',

	'name'=>'My Web Application',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),

	'modulePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'/controllers',


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'My Gii Pass',

		),

		'admin'=>array(

		'viewPath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'templates/backend/basic/views'

		),

		

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		// uncomment the following to enable URLs in path-format

		/*

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		*/

		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=whp',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		'config'=>array(

			'class'=>'application.extensions.EConfig'

		),

		

		'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);



Thx alot for you kindness =))) I got couple of questons :

[list=1]

[*]why are you not using urlManager?

[*]Is it ok for you to have 2 db components?

[/list]

  • why are you not using urlManager?

    I will use it based on requirements.

    • Is it ok for you to have 2 db components?

    No problem. We can have as many DB connections as we need.