Jul
15

Ayphix Discord

Ayphix now has an official discord channel! Please pop in and hang out! Official Discord Channel
Fayte   0   No Categories
Read more
Apr
18

Switching servers

We will be switching servers within the next day or so. You may experience some down-time we apologize for any inconvenience this may cause.
Fayte   0   No Categories
Read more
Mar
16

The making of Softlight Framework V2

Overview


In early 2014 the first version of Softlight Framework was started after many years of planning. The idea was to create a system that could be used to create Web Applications more easily. Being a software company that makes custom software this was imperative to our vision and productivity.

The implementation of this was our block system. I’ll break this down so you can better understand.

Block System V1



The original block system was parsed from the template string as such
[Block_Name id=”Block id” skin=”Block skin” …more=”attributes”]
at which point it looked for a “Block_Name.php” in the models directory and ran it. This was done at the end of the template section so that blocks stored in the database were also parsed using regex. This system vastly improved the speed of developing a PHP web application. Not only that, but it also made making changes to blocks easier as any changes to the block logic changed it for all the blocks using that logic.

V1 Block Issues



V1 of the block system had some glaring issues. Blocks within blocks were only allowed to go 2 blocks deep. As it required a while statement to check the blocks output for new blocks. So as a safeguard we limited nested blocks to 2 blocks deep.

Secondly, it ran 2 regex calls as the first one parsed the blocks skin and replaced the output tags with the data being passed to them. And then the second to check for any blocks introduced by this step.

Thirdly, since it used the internal code igniter template parsing system if you passed an object to the template replacement array you couldn’t access that objects properties. This is the same if you passed in a nested array, there was no way to access array elements.

Those were the top three issues but let’s list off just a few more for good measure

No ability to do nested for-each loops
Formatting the replaced data for things like dates. This would have to be done in the block logic controller
To use if statements to remove elements from the page or display them in different ways depending on the data would needed in-page PHP. Something we we’re activelty trying to avoid.
Slow
Obviously there are many more issues but these are just the glaring ones.

Solution



At first I thought of scrapping the code igniter template parsing library, this was a good idea only as far as I could throw it. The issue, is that it would cause me to have to re-write large portions of the block system. Even then; 50% of the issues still remained. I took a step back, re-analyzed the problem and came to the conclusion that I was going to have to write quite an intricate parsing system. So I started simple, and things started becoming more and more clear that the best way forward was to write a simple scripting language.

The birth of Softlight Framework 2



When I started working at my current job (GLS) I was exposed to angular, my first impression? “Why would… What the? Who in their right mind would use this?” after a few weeks I began to find a few things angular did really well. So it got me thinking, what if I took the good things angular did right and put them into SLF? I immediately started to write an HTML parser, in my excitement I completely forgot to look to see if there was anything pre-made I could use. Initial tests were good! I could write skins in pure HTML and use HTML attributes to add little snippets of logic. First was sl-repeat and then came sl-hide. Soon I realized I need a slightly more robust system so I found the “simple_html_parser” which has worked out incredibly well.

So how does it work?



The SLFv2 System traverses the DOM before it’s sent to the browser and looks for cues as to what to do. After that the HTML is passed to your web server and sent to your browser to be parsed into a DOM object. With the special attributes stripped out to prevent older browsers from having seizures over it. This also allows you to remain W3C compliant if that’s your thing.

In the immortal words of Billy Mays: “But wait there’s more!” the block system in SLF is still just as alive and well as SLFv1 just more powerful and easier to use! SLF blocks are easy to create and modify. The logic for the blocks is contained within it’s own scope. While still allowing the skin code to be embedded right into your HTML. Once it comes across a tag it doesn’t recognize it checks an array of predefined blocks and then runs their code. Replacing the block with the parsed and processed HTML, super useful. You can also call and use functions, and many more things from your block as well. Say for instance your making a blog system and you want to only show the edit buttons to admins. You put this logic in your block class and then call sl-hide=”!checkForAdmin()” and that element along with all it’s children will never be sent to the browser.

The last piece that makes up the skin parsing abilities of SLFv2 is output tags they look like this: “ {:some_var:}” that tag using regex and preg_replace will be replaced with a selected variable.

SL-Script?



SL-Script is a language created directly for use inside of the SLFv2 skin parsing system. It’s parsed character by character and is very fast and efficient. This get’s translated into pure PHP code and run in it’s own contained environment.

Conclusion



Thinking outside of the box created a really great system. And it’s open-source unlike the first iteration of SLF. So feel free to download and use it just if you make any bug fixes or improvements please pull request them into the official repo for everyone to benefit from. SLF3 will probably not use code-igniter or the “simple_html_parser” but for now SLFv2 works great so there’s no reason not to use it.

SLF2 Repo



a href="https://github.com/AyphixEntertainmentLLC/SoftlightFramework2">https://github.com/AyphixEntertainmentLLC/SoftlightFramework2
Fayte   0   No Categories
Read more
Dec
02

Be a part of the beta!

As new feature's are added, they will be first introduced into the beta ayphix site, which is a direct mirror to the main site with one twist, it has all the new features as they arrive. Which means, things could be broken. If you want to be a part of the beta and stand on the cutting edge. You can do so at the Ayphix Beta Site. There is no obligation, and nothing limiting you from coming back to the stable version. Simply drop the "beta." from the url and BOOM you're back here easily switching back and forth. So what are you waiting for? Click Here to go there.
Fayte   0   Development, News
Read more
Nov
27

Welcome to the new Ayphix.com!

This is the new Ayphix.com! It is built using our free open-source framework known as Softlight Framework 2. (The original was built on Softlight Framework 1) This website is currently under open beta and there may be some errors. If you see any please use the submit a bug function in the UserCP.
Fayte   0   News
Read more