Hello to all residents and guests of Habr and happy new year! :)
In this article I want to talk about what features Jii has entered in 2016, and what awaits him in the new year.
So let's start in order.
Console application
The console application has been updated, now it supports the methods prompt, select, confirm, and the like from the
Console helper (
\ yii \ helpers \ BaseConsole ). If the application is initialized through
jii-workers (
an article on Habré ), then the console application will start when adding a route as an argument:
jii migrate/create
Thus, the jii file (
example ) becomes input accurate for both the console application and the web.
The console application has the
“console” key; for its configuration, you must pass the configuration object with the
console key to the
application () method:
require('jii-workers') .application('console', Jii.mergeConfigs(
If you omit the arguments, then the web application starts. Run
jii help to view the available console commands.
')
Migrations
In version 0.8, migrations ported from Yii2 appeared. All the functionality and API is saved, the only thing missing is the tests. If you find a bug, then make a pull request with a fix or
create a ticket .
Class loader
Now Jii knows about all its classes in any of the packages (
autogenerated list ), which means that when you connect Jii, you do not need to require (..) to include all the packages, you only need to connect jii:
And if you forgot to install any of the packages, in the console you will see a clear error indicating this.
Backbone-style models and collections
In Jii, there were collections and models, whose API is similar and in many respects repeats API Backbone (with API Yii2 models saved). In addition, in the models and collections added events that support nesting. Those. If the model has connections, then you can subscribe to changes in the associated model, even if it is not loaded yet. Similarly, getters and setters have become smarter.
Here is a small list of supported formats for receiving / adding / changing values and subscribing to events:
Collection formats: coll.add({id: ..}) coll.push({id: ..}, {id: ..}) coll.add([{id: ..}]) coll.set({id: ..}) coll.set('[0].name', '..') coll.at(-1).get('name') coll.on('add remove change', function (){}) coll.on('change:title', function (){}) coll.on('change:user.name', function (){}) Model formats: model.set('name', '..') model.set('foo.bar', '..') model.set('foo[0].bar', '..') model.get('foo.bar.zz.rr[0].qwe') model.get('foo[0].bar') model.on('change', function (){}) model.on('change:foo', function (){}) model.on('change:foo.bar.qwe', function (){}) model.on('change:foo.bar[0].qwe', function (){})
Unfortunately, there is no documentation yet, but you can see the tests of
collections and
models .
ReactJS
Initially, I planned not to make hard bindings to views, I wanted any client or server library responsible for the letter “V” from “MVC” to work with Jii without complicated tambourine tricks. As it became clear later, it is very difficult to combine large frameworks such as angularjs, sencha because of the presence of their models in them.
We began the search for views for Jii: they had to be up-to-date, with data bindings that were not tied to the structure of the application, preferably isomorphic. Reactive Facebook views fit perfectly into these criteria, so an alternative has been added to the underscore templates - ReactJS.
Isomorphic application
ReactJS was originally created to be isomorphic, controllers in Jii were isomorphic and earlier, models and collections were pumped. Also, there are such components as Neat, ContextProfiles, RemoteConnection, etc., which allow you to make the code isomorphic. All this is still in alpha, so many examples, tests, stability and documentation are not available right now. But there is a
boilerplate showing the capabilities of the new features.
Client-server Binding
Bindigs are implemented through the
NeatComet library, which was developed by a colleague from our company (
ExtPoint ). It is already used in some projects, but is not yet ready for mass publishing. In the case of Jii, it doesn't matter, because Jii has its own API on top of NeatComet.
2016
All of the above and other features will be developed in the 2016th year. There are many plans, there are more ideas, but as usual there is little time.
Let me remind you, Jii is an open source project, so I will be very happy if someone joins its development. Write to affka@affka.ru and look in the development section.
Framework Site -
jiiframework.ruGitHub -
github.com/jiisoftLike the idea of the framework? Put a star on the githaba !