Wednesday 15 November 2017

php - YII Newbie questions

itemprop="text">


I am testing an MVC
framework to use in my project and i have few questions regarding the
YII.




  1. I have
    create a model using GII, I know from java the code generation suppose to be a helper
    and most of the time should not be modified, because you may want to regenrate in the
    future, how is that suppose to work
    here?


  2. I have created a CRUD out of the
    model and it gave a nice gui for it, I want to keep the gui for the admin side but i
    want to do a different one for the user side, what is the approach
    here?


  3. If i am deciding to use some ORM
    in my app, this means that i need to create a different model, and i see that the
    current model inherits from an other one... problem?



    In
    general


  4. Which is
    suppose to be faster in terms of load, CI? or
    YII?


  5. correct me If i am wrong but MVC
    architecture does not really gives you a way to be really OOP, like java. interfaces,
    inheritance and polymorphic, it is a nice way to build a nice app quickly, not more than
    that. I am saying that because your controllers and model are already inheriting some
    classes.





Thanks



Answer




1) Usually models work ok after generation
and most of time there's no need to change anything. If you add a field in your database
and you need to regenerate it, when you do that you have in gii what's the new code, so
you can copy/paste. Usually you don't need to do that, when i add fields to a database I
add those fields in the model "by hand". Very easy and quickly, trust
me



2) use templates. Create a new template in
your layout views, and assign it to the controllers of the front end with
$this->layout = '//my//layout';



3) Yii AR
implementation is enougth for me. Can't answer to this questions, but you should not
have any problem.




4) Depends on what
kind of app you are running. I have worked with CI and Yii, i prefer yii for developer
time and for speed.



5) You are "right" with that
point.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...