Client-side models for Backbone and Angular #1471

Closed
evilebottnawi opened this Issue Dec 10, 2013 · 19 comments

Comments

Projects
None yet
6 participants
@evilebottnawi

It would be really useful for Backbone and Angular apps to auto-generate models and validation for field of models(recently, a very developed full-ajax application and would like to yii also developed in this direction. Also use engine is a realtime model synchronization(example for nodejs is https://github.com/codeparty/racer). Implementing such a system will allow further development of complex applications comfortable.

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Dec 10, 2013

Member

That's out of scope of core framework.

Member

samdark commented Dec 10, 2013

That's out of scope of core framework.

@samdark samdark closed this Dec 10, 2013

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 10, 2013

I do not think it out of scope core framework.
Ruby/Ruby on rails - https://github.com/meleyal/backbone-on-rails
Python/Django - https://github.com/jrief/django-angular
PHP/Zend2 - https://github.com/hantsy/angularjs-zf2-sample
PHP/Sympfony - https://github.com/rajasaur/angular-symfony-demo.
This is a quick run through the list. The list could go on and plus almost every project, there are alternatives to the use of libraries for generating models. In the near future, many frameworks will bear part of the code in the core. Yii always been comfortable, beautiful and progressive framework. And it would not be bad if he did such a transition is one of the first. I often need to create Ajax applications and every time I have to create from scratch a front-end code for the project. Do not have a framework to simplify my work?

I do not think it out of scope core framework.
Ruby/Ruby on rails - https://github.com/meleyal/backbone-on-rails
Python/Django - https://github.com/jrief/django-angular
PHP/Zend2 - https://github.com/hantsy/angularjs-zf2-sample
PHP/Sympfony - https://github.com/rajasaur/angular-symfony-demo.
This is a quick run through the list. The list could go on and plus almost every project, there are alternatives to the use of libraries for generating models. In the near future, many frameworks will bear part of the code in the core. Yii always been comfortable, beautiful and progressive framework. And it would not be bad if he did such a transition is one of the first. I often need to create Ajax applications and every time I have to create from scratch a front-end code for the project. Do not have a framework to simplify my work?

@nineinchnick

This comment has been minimized.

Show comment
Hide comment
@nineinchnick

nineinchnick Dec 10, 2013

Contributor

Shouldn't a gii template for JS models be enough? This could be created as an extension and later incorporated in the core if it meets the quality and other requirements.

Contributor

nineinchnick commented Dec 10, 2013

Shouldn't a gii template for JS models be enough? This could be created as an extension and later incorporated in the core if it meets the quality and other requirements.

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Dec 10, 2013

Member

@sheo13666 all your examples are pointing to third party repositories, not core framework. If you're talking about REST, there is issue already filled for it: #303

Member

samdark commented Dec 10, 2013

@sheo13666 all your examples are pointing to third party repositories, not core framework. If you're talking about REST, there is issue already filled for it: #303

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 10, 2013

@nineinchnick Yeah, I think gii suitable for this solutions. I would not want to see this issue with the label closed, perhaps someone interested in further improvement.Eg generation routers(to navigate the page without updating) and etc, all that with regards to complex and ajax applications.

@nineinchnick Yeah, I think gii suitable for this solutions. I would not want to see this issue with the label closed, perhaps someone interested in further improvement.Eg generation routers(to navigate the page without updating) and etc, all that with regards to complex and ajax applications.

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 10, 2013

@samdark About Rest I have read and know. No I did not mean it. I said that many have not included it in the part of core, but I do not think it would be bad, if yii to do it first.

@samdark About Rest I have read and know. No I did not mean it. I said that many have not included it in the part of core, but I do not think it would be bad, if yii to do it first.

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 10, 2013

Writing ui for working with models(most often it is required) on fornt-end: validation, changes in events and more is not very convenient on jquery(most often we get a lot of unstructured code). I understand that the creation of any Ajax application - it's hard work, but if it is possible to alleviate then why not?

Writing ui for working with models(most often it is required) on fornt-end: validation, changes in events and more is not very convenient on jquery(most often we get a lot of unstructured code). I understand that the creation of any Ajax application - it's hard work, but if it is possible to alleviate then why not?

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Dec 10, 2013

Member

Well, it's different for each clientside library and there are many. We can't support them all in the core.

Member

samdark commented Dec 10, 2013

Well, it's different for each clientside library and there are many. We can't support them all in the core.

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 10, 2013

I understand that, but sooner or later they will have to implement it. And it might be worth to explore and have a discussion that is better to use. Or if enough developers to develop their own.

I understand that, but sooner or later they will have to implement it. And it might be worth to explore and have a discussion that is better to use. Or if enough developers to develop their own.

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Dec 10, 2013

Member

When someone will implement it and release as an extensions, others may contribute. We have no plan doing it currently. Too many other things to handle.

Member

samdark commented Dec 10, 2013

When someone will implement it and release as an extensions, others may contribute. We have no plan doing it currently. Too many other things to handle.

@qiansen1386

This comment has been minimized.

Show comment
Hide comment
@qiansen1386

qiansen1386 Dec 11, 2013

Contributor

Don't. Please. Please don't.
Have u imagine if we put CC script in Yii-core, How many new beginners may
be scared away?
It is way too far for a "PHP" developing framework. And you can't make sure
that almost every body will use it like bootstrap, and if i was not wrong,
even bootstrap is not included in Yii Core.

2013/12/10 Alexander Makarov notifications@github.com

When someone will implement it and release as an extensions, others may
contribute. We have no plan doing it currently. Too many other things to
handle.


Reply to this email directly or view it on GitHubhttps://github.com/yiisoft/yii2/issues/1471#issuecomment-30220233
.

Contributor

qiansen1386 commented Dec 11, 2013

Don't. Please. Please don't.
Have u imagine if we put CC script in Yii-core, How many new beginners may
be scared away?
It is way too far for a "PHP" developing framework. And you can't make sure
that almost every body will use it like bootstrap, and if i was not wrong,
even bootstrap is not included in Yii Core.

2013/12/10 Alexander Makarov notifications@github.com

When someone will implement it and release as an extensions, others may
contribute. We have no plan doing it currently. Too many other things to
handle.


Reply to this email directly or view it on GitHubhttps://github.com/yiisoft/yii2/issues/1471#issuecomment-30220233
.

@nizsheanez

This comment has been minimized.

Show comment
Hide comment
@nizsheanez

nizsheanez Dec 14, 2013

actually, i working now with angular + yii2, and model for angular looks like:
var User = $resource('/api/v1/user/');` - it's REST model
Or with some custom methods.

$resource('/api/v1/user/', {}, {
        getSomeDataMethod: {
            method: 'GET',
            params: {
                fullData: true
            }
        }
    });

of course there is must to be some ModelFactory and so on, but
actually i don't see what need to generate there.
jsDock? - maybe
getters for relations? - nobody use simple relations, only with some scopes and so on.
what else?

now i working on angular models which will works with websockets(just change transport :-) and maybe later will implement autoupdate).

Maybe just need to create demo app, for showing how to use good practice, but what generate i don't see.

@sheo13666, can you get more details what you want to see?

actually, i working now with angular + yii2, and model for angular looks like:
var User = $resource('/api/v1/user/');` - it's REST model
Or with some custom methods.

$resource('/api/v1/user/', {}, {
        getSomeDataMethod: {
            method: 'GET',
            params: {
                fullData: true
            }
        }
    });

of course there is must to be some ModelFactory and so on, but
actually i don't see what need to generate there.
jsDock? - maybe
getters for relations? - nobody use simple relations, only with some scopes and so on.
what else?

now i working on angular models which will works with websockets(just change transport :-) and maybe later will implement autoupdate).

Maybe just need to create demo app, for showing how to use good practice, but what generate i don't see.

@sheo13666, can you get more details what you want to see?

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Dec 15, 2013

@nizsheanez I think it would be good to create a demo. How about the other components(views, routing)?

@nizsheanez I think it would be good to create a demo. How about the other components(views, routing)?

@nizsheanez

This comment has been minimized.

Show comment
Hide comment
@nizsheanez

nizsheanez Dec 16, 2013

Routing

'api/v1/<controller:\w+>'                            => 'v1/<controller>/index',
'POST api/v1/<controller:\w+>/<id:\d+>'     => 'v1/<controller>/save',
'DELETE api/v1/<controller:\w+>/<id:\d+>' => 'v1/<controller>/delete',
'api/v1/<controller:\w+>/<id:\d+>'               => 'v1/<controller>/view',

using module for versions is not good, but to push controllers in folder, like v1 v2 i don't know good solution in Yii2, need to investigate it.

views - just layout. everything else on angular

Routing

'api/v1/<controller:\w+>'                            => 'v1/<controller>/index',
'POST api/v1/<controller:\w+>/<id:\d+>'     => 'v1/<controller>/save',
'DELETE api/v1/<controller:\w+>/<id:\d+>' => 'v1/<controller>/delete',
'api/v1/<controller:\w+>/<id:\d+>'               => 'v1/<controller>/view',

using module for versions is not good, but to push controllers in folder, like v1 v2 i don't know good solution in Yii2, need to investigate it.

views - just layout. everything else on angular

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 7, 2014

Contributor

@nizsheanez thanks for your description. I'm developing a Yii2 app and running against the limitations of a static lay-out rendered on the server side.

I have 2 questions for you:

  1. why is using modules for API versions not a good idea?
  2. as I understand it, your layout is rendered once (server side) and subsequent requests are rendered by the client. How does this work out for you? Do you use a templating system (like Ember or Handlebars) or something more limited like AngularJS?

thanks!

Contributor

ghost commented Feb 7, 2014

@nizsheanez thanks for your description. I'm developing a Yii2 app and running against the limitations of a static lay-out rendered on the server side.

I have 2 questions for you:

  1. why is using modules for API versions not a good idea?
  2. as I understand it, your layout is rendered once (server side) and subsequent requests are rendered by the client. How does this work out for you? Do you use a templating system (like Ember or Handlebars) or something more limited like AngularJS?

thanks!

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Feb 7, 2014

Handlebars is good solution

Handlebars is good solution

@nizsheanez

This comment has been minimized.

Show comment
Hide comment
@nizsheanez

nizsheanez Feb 7, 2014

@docsolver

  1. i don't know how to put controller into a folder like v1 inside module, maybe it's already possible.
  2. I render layout with css and js(early i used yii2 bundles for this, now i use grunt, just becasue grunt has plugins ng-min for angular minification), a bit html and base data for application initialisation without requests to server(rich js applications can start render only after js will download and run, it's enough long, and i think application must have all data for immediately run).
    I use Angularjs just because i like declarative style of this framework, nothing more.

@sheo13666
very nice answer for developers community

@docsolver

  1. i don't know how to put controller into a folder like v1 inside module, maybe it's already possible.
  2. I render layout with css and js(early i used yii2 bundles for this, now i use grunt, just becasue grunt has plugins ng-min for angular minification), a bit html and base data for application initialisation without requests to server(rich js applications can start render only after js will download and run, it's enough long, and i think application must have all data for immediately run).
    I use Angularjs just because i like declarative style of this framework, nothing more.

@sheo13666
very nice answer for developers community

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Feb 7, 2014

@nizsheanez I was looking for a method of using grunt with yii, but did not find a recipe, I would like to know whether this is possible in a convenient way.

@nizsheanez I was looking for a method of using grunt with yii, but did not find a recipe, I would like to know whether this is possible in a convenient way.

@nizsheanez

This comment has been minimized.

Show comment
Hide comment
@nizsheanez

nizsheanez Feb 7, 2014

@sheo13666 Actually what we need from Yii in this case?
Only list of css and js files.
So, it's not a problem to create Yii console command which will generate Grunt.js file and then run grunt, because grunt must be run under www-data:www-data user.
List of file we can get from main app bundle.
Same for output file path.
Same for Live reload feature of grunt.

So, i think it's easy to create console wrapper over grunt.
I don't have it now ;-)

@sheo13666 Actually what we need from Yii in this case?
Only list of css and js files.
So, it's not a problem to create Yii console command which will generate Grunt.js file and then run grunt, because grunt must be run under www-data:www-data user.
List of file we can get from main app bundle.
Same for output file path.
Same for Live reload feature of grunt.

So, i think it's easy to create console wrapper over grunt.
I don't have it now ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment