Yii Project Planning & File System Layout
Posted 25 October 2011 - 08:30 PM
I stumbled upon this article, written by qiang in the Wiki.
Now that I have seen this, everything about Yii and how to actually make a real world project happen --- is starting to make sense.
I really like this structure and now I need to figure out how to implement it! As it is right now, I run 'yiic webapp /path' and it makes a project show up. How do I implement this new project structure?
Is there a command? (doubt it, but had to ask...)
If I take the generic "webapp" that yiic produces and just move the folders around, will that be sufficient or would I just need to perhaps update the path locations in a config file somewhere?
Ideally, if I could translate the project structure into:
I guess I'm struggling on where to get started with this....am I on the right track?
Posted 25 October 2011 - 09:12 PM
Posted 25 October 2011 - 10:23 PM
Ok, I'll start there. The wiki page had a few nice commands to get the file structure setup, then I could just drop my files into the right places....or modify the pre-generated version.
How would application access work? In my post I noted a few links, so if I had /backend/ as a Yii application folder, it would be like a subdirectory in the actual website (for example)?
I'll struggle with it tomorrow morning, but I'm wondering if it is all THAT straight-forward. My spider sense is telling me "no".
Posted 26 October 2011 - 10:46 AM
At least that's how I understood it. So there really isn't a protected folder, its all outside the "www" folders, which are now nested inside each "application".
Does that make sense? Aside from your ideas, I'm not sure how to get this implemented. I'll start playing with it now and see what happens.
Posted 26 October 2011 - 01:25 PM
1. Edit you config/main.php in backend and frontend to have the "site" level path alias included:
2. Import the shared models, using the config/main.php in backend and frontend like this:
// autoloading model and component classes 'import'=>array( 'application.models.*', 'application.components.*', 'site.common.models.*', )
Done....pretty cool if you ask me. Now I can build models for data tables that get accessed from both the backend and frontend of my application. In the future, I'll add an API application to the mix and it will be a snap!
More people should use this structure, it's really the piece I was missing from the initial yiic generated code! If the yiic sample stuff leaves you scratching your head and wanting more, then this will surely satisfy the itch!