CleverStyle Framework 4 Release

    Somehow I couldn’t write more than one article from the beginning of a new branch ( part 1 , part 2 , part 3 ), but again there is something interesting to tell, because the first release of the 4.x series was released .

    Briefly about everything


    The first thing I would like to say is that the project was renamed from CleverStyle CMS to CleverStyle Framework. At last! There will no longer be confusion between title and content.

    If 2.x series started with significant changes on the server side, and 3.x with comparable changes on the client, then 4.x brings improvements everywhere.

    The server speed has been significantly increased, despite the fact that this is a full-stack framework, using an HTTP server based on ReactPHP you can get the page generation speed BELOW 1ms, HTML generation in typical scripts has become faster.
    It also added convenient support for nested structures in translation files, added support for SQLite, PostgreSQL, support for working as a PSR7 Middleware (initialization from a PSR7-compatible request object and outputting the result to a PSR7-compatible response object), and convenient abstractions in the kernel associated with this .

    RequireJS is widely used on the front end, a number of libraries that are unconditionally loaded on the front end are now loaded only when needed, optimizations are added for quick rendering of the first frame (first paint).

    At the junction of the backend and frontend optimizations for building the static cache (CSS / JS / HTML), HTTP / 2 Server push, and much more. In general, the system looks like a good hybrid (not purely microkernel, but not so bold) full-stack php framework.Link:



    As always, there were some improvements to code metrics, for example, Scrutinizer ratings :)

    Polymer and web components


    You can start with the same thing as the last article - with web components.

    Polymer itself still comes patched, but for a different purpose. All important PRs were accepted, 2 not accepted ones are delivered as runtime patches and are not affected by the build itself. But now, from the Polymer assemblies used in the system, support for Shady DOM has been cut out, since the system uses the full version of Shadow DOM (and full polyfill where there is no support). As a result, the build is significantly less than the original.

    Polyfill WebComponents.js is also optimized. Firstly, all polyphiles for IE / Edge (which are connected only for the mentioned browsers) are cut out of it, WebComponents.js is also not connected for Chromium / Chrome, because it is simply not needed there.

    Web components themselves are being used more and more, for example, now modules have been refactored using them: Blogs, Comments, Disqus, and the system has long been using them for everything.

    The system also learned how to better minify HTML files, now all JSs are combined and some errors of the early implementation have been fixed.

    RequireJS (Alameda)


    This is actually a very important feature. In the latest version, instead of RequireJS, a more modern and compact (but backward compatible) analogue from the same developer Alameda is used.

    RequireJS is integrated at all levels:
    • third-party libraries, such as autosize, html5sortable and jssha, supplied with the kernel, are actually used exclusively as AMD modules and nothing else (jQuery is expected to be rendered similarly in 5.x)
    • all components can use AMD modules for their own needs very simply, for example, components/modules/Blogs/includes/js/xyz.jsyou can transparently load as a module Blogs/xyz(subfolders are also supported)
    • when at the root of the site bower_componentsand / or node_modulesfrom Bower / NPM are detected , AMD modules will be automatically searched, so you can immediately call require(['lodash']).then(function (_) {})without preliminary configuration
    • similar to root Bower / NPM folders, dependencies installed through the Composer assets plugin will be processed in a similar way, becoming available by name without any paths
    • moreover, if you look at the modules installed through Composer assets in the absolute path, as if they were installed in the root, for example, /node_modules/d3/d3then everything will work as if the dependency were actually installed there!


    Thus, the amount of necessarily downloaded code has significantly decreased, will be reduced further in the 5.x series, and the developer gives even more potential.

    IE 10


    Time is running out, in the kernel only __proto__ is not used for compatibility with IE 10, the rest of the compatibility burden has been moved to the new Old IE plugin , which will support IE 11 in the 5.x series.

    Request / Response, PSR7


    Now a little about the server side. System objects were added cs\Requestand cs\Responseboth can work with PSR7 , and both provide re-initialization as needed.
    All this together greatly simplified the use of the framework as Middleware, which can be seen on the example of how integration with ReactPHP is happening now .

    Since reinitialization is provided automatically at the kernel level, it has become possible to never recreate system objects at all, and instead only reinitialize the necessary parts. This allows you to achieve page generation faster than 1ms.

    Along with support for abstractions, a standalone fully streaming parser of multipart requests was written, so file uploading will work with any method, not just POST, the site will not break when enable_post_data_reading = Offin php.ini (under ReactPHP there is still no support for uploading files , I really hope that in the near future a new release will be released with https://github.com/reactphp/http/pull/41 in its composition).

    SQLite / PostgreSQL


    These two database drivers were fully added to the kernel, but are not yet supported by any of the modules (this is temporary). SQLite can be used for simple sites where the database itself is not needed at all, but the system requires it to store the configuration and settings of a single administrator. In this scenario, SQLite will not slow down, because caching will reduce its use to zero in the vast majority of cases.

    Sessions


    The sessions turned out to be an interesting story with a good ending. Historically, the system uses a custom session system, which is more flexible than the built-in one, scales well and works very quickly.

    Quickly, but not by as much as there can be no sessions at all. As a result, the latest versions of the system do not start a session on the user until he uses something for which sessions are actually needed. This allows you to avoid queries in the database on standard pages for users who first arrived on the site.

    Namespaces in translation files


    The feature begs for a long time. First, there was support for prefixes in objects with translations, then prefixes began to bother in the translations themselves, so now you can do it easier:



    HTTP / 2 Server push, preload


    Recent versions of Chromium / Chrome support the preload header / meta tag , which tells the browser that this resource is needed 100% of the page, load it even if you still don’t understand why, I know for sure that it will be needed.
    The same attribute is used by nghttp2 and CloudFlare for HTTP / 2 Server push.

    Since the framework initially has information about what static resources are and the dependencies between them, and during minification and compression, he also knows what pictures, fonts and other things are used inside the resources, he uses this information to generate the corresponding headers, which is the most positive image affects page load time.

    CLI interface


    The latest release also brought a useful kernel level CLI feature. So far, little is available through it, but very soon there will be more. Plans for it are large both in the kernel and in the components, although now you can do something useful, well, or use it in your components :)

    Updates


    Components Blogs, Comments, Composer, Disqus, Uploader, Composer assets and TinyMCE use the latest convenient kernel features, and are examples of how to make components in the modern version of the framework. The remaining components for the most part were simply ported for compatibility with new versions and do not use the system’s potential to 100%, but will be in subsequent updates.

    Third-party dependencies have been updated to the latest versions at the time of release.

    Documentation


    After some deliberation, the documentation was transferred to the same repository as the source code. Firstly, it’s easier to synchronize changes, and secondly, you can now see the documentation, which it was in older versions of the system if necessary (or compare changes in the documentation from version to version), which could not be done in a simple way with the wiki.

    Scrutinizer


    I don’t know whether it is a lot or a little, but from 7.74 to 8.15 the rating has risen, and the distribution has changed significantly:



    Video tutorials for developers


    I started to record screencasts on how to use the system, I hope they will help to quickly and easily start using the system, orders are being accepted for what aspects of the system are of primary interest and generally any comments on this matter.

    Those who want to chat with a chat room can do this in Gitter . GitHub
    code , documentation in the docs folder . You can run the touch with one line using Docker (it is better to use Firefox, Chromium does not want to set a cookie on localhost):


    docker run --rm -p 8888:8888 nazarpc/cleverstyle-framework
    

    Also, the new version is used on cleverstyle.org (with HTTP / 2 and other joys).

    Also popular now: