Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are we free to put models in any folder location? #107

Open
developedsoftware opened this issue Mar 29, 2021 · 5 comments
Open

Are we free to put models in any folder location? #107

developedsoftware opened this issue Mar 29, 2021 · 5 comments

Comments

@developedsoftware
Copy link

I realise documentation is not complete and yii3 is still in development. I am just trying to plan a migration from yii2 to yii3 and the only thing I cannot seem to work from this project is where I stick my "models"

Apologies if this is a stupid question. Very much have my Yii2 hat on.

Is there a recommended directory structure?

@Mister-42
Copy link

Mister-42 commented Mar 29, 2021

My personal approach: keep controller, models and views close together. General Models in a separate folder Models.

I would like to know a recommended or standardized way as requested though.

@developedsoftware
Copy link
Author

I imagine we can put them anywhere. But I agree some structure and keeping them together is best.

Do you seperate your business logic into folders like “Blog” and then have controllers, models and views under this directory or in subdirectories ?

@Mister-42
Copy link

Since I have URLs like https://www.domain.tld/category/page I placed files like this:

Control
 - Controller.php
 - Category
   - page.php (view)
   - page
     - AR.php
     - Model.php
Models
 - GenericModel.php

I'm sure it's not perfect, but works alright for me. I can always find the files fast I need to edit.

@samdark
Copy link
Member

samdark commented Mar 31, 2021

@Mister-42 approach is alright. That should be added to yiisoft/docs.

@samdark samdark transferred this issue from yiisoft/demo Mar 31, 2021
@samdark
Copy link
Member

samdark commented May 11, 2022

See yiisoft/app#238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants