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

Client-side models for Backbone and Angular #1471

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

Client-side models for Backbone and Angular #1471

evilebottnawi opened this issue Dec 10, 2013 · 19 comments

Comments

@evilebottnawi
Copy link

@evilebottnawi evilebottnawi commented Dec 10, 2013

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
Copy link
Member

@samdark samdark commented Dec 10, 2013

That's out of scope of core framework.

@samdark samdark closed this Dec 10, 2013
@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented 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?

@nineinchnick
Copy link
Contributor

@nineinchnick 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
Copy link
Member

@samdark 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
Copy link
Author

@evilebottnawi evilebottnawi commented 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.

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented 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.

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented 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?

@samdark
Copy link
Member

@samdark 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
Copy link
Author

@evilebottnawi evilebottnawi commented 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.

@samdark
Copy link
Member

@samdark 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
Copy link
Contributor

@qiansen1386 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//issues/1471#issuecomment-30220233
.

@nizsheanez
Copy link

@nizsheanez nizsheanez commented 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?

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented Dec 15, 2013

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

@nizsheanez
Copy link

@nizsheanez nizsheanez commented 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

@ghost
Copy link
Contributor

@ghost 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
Copy link
Author

@evilebottnawi evilebottnawi commented Feb 7, 2014

Handlebars is good solution

@nizsheanez
Copy link

@nizsheanez nizsheanez commented 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

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented 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
Copy link

@nizsheanez nizsheanez commented 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 ;-)

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.