Introducing Wave Framework

June 7, 2012 at 23:41

Wave Framework

Wave Framework

Wave Framework is an open source API-centric PHP micro-framework. First release of Wave was in February 2012 and the code has been through refactoring, multiple patches and bugfixes since. Wave puts strong emphasis on API-based web development. The project has gained some recognition on Google+ and today has more than a thousand followers. The name ‘Wave’ comes from the use of ‘www’ prefix across the system which looks like symbolic waves.

Wave is a PHP micro-framework that is built loosely following model-view-control architecture and factory method design pattern. It is made for web services, websites and info-systems and is built to support a native API architecture, caching, user control and smart resource management. Wave is a compact framework that does not include bloated libraries and features and is developed keeping lightweight speed and optimizations in mind. While not necessary for using Wave Framework, it comes by default with a URL and View controllers intended for building websites by solving URL requests and loading views.

Mercurial and Git repositories is available for developers who are interested in following the development.

Documentation about how to set up a system and use the API, as well as tutorials are available on the official website of Wave Framework.

Features:

  • Modern API-centric framework for PHP versions 5.3 and above
  • Secure API requests with hash validation, token and key-based authentication
  • Dynamically loaded Hierarchical MVC objects through Factory pattern
  • API returns XML, CSV, JSON, HTML, native PHP and other data formats
  • Compressed data output with Deflate and Gzip
  • Input and output data is fully UTF-8
  • PDO-specific database controller for general-use database connections
  • Index gateway and Handlers for all types of HTTP requests
  • Caching system with tagging support for all types of dynamic and static requests
  • View and URL Controllers that support multiple languages and clean URL’s
  • Users and permissions control
  • jQuery JavaScript framework supported
  • On-demand dynamic image resizer and editor
  • On-demand resource compression, unifying and minifying
  • Automatic sitemap.xml and robots.txt generation
  • Automatically generated API documentation
  • API wrapper classes that make browser and server to server communication easy
  • 256bit Rijndael encrypted data transmission
  • API Observers for creating event-specific listeners
  • Installation-specific MVC class and resource overrides
  • Custom on-demand session handling
  • Request limiter that can block HTTP requests under certain conditions
  • Request logger that can be used for detailed performance grading of HTTP requests
  • Debugging, backup, update and filesystem maintenance tools
  • Compatibility script that tests support for server setup
  • Supports Apache and Nginx servers in Linux and Windows environments
  • Test Suite for API Testing
  • Filesystem caching, database cache, APC and Memcache supported
  • 100+ pages of detailed documentation and tutorials
  • Licensed under GNU Lesser General Public License Version 3

You can follow news related to the project on various social media channels Google+FacebookTwitter and source code is officially published at SourceForgeGoogle Code as well as BitBucket and GitHub.


Tags: , , ,

17 Responses to “Introducing Wave Framework”

  • ALLAN D says:

    Hello, I just got an email blast about your product from the PHPClasses Contem. I have spend about 8 months building a rather hefty solaris environment load balanced servers (multiple application servers nginx + apache + php), postgre database cluster, etc. But I am fairly new, well absolutely new to coding php. I have about 13 years IT work and am wondering if this tool will get me off the ground quickly coding my dream website which I am building now. I am looking for a good tool to generate user managegement and security stuff to manage user logins, product availability, etc.

    I want to get off on the right foot, and your emphasis on saying the product is not full of bloat like I have seen in other products has caught my attention.

    Thanks,
    Allan

  • Kristo Vaher says:

    Hi Allan!

    Wave Framework can be used by beginners, but of course it takes a longer time to get a grip on various concepts of web development, MVC and object-oriented programming with PHP. Wave is trying to give a middle-ground between software that you are building and the web servers and browsers. I originally started developing it since I was tired of either ignoring some important concepts, or just tired of writing the same code again and again. And I decided that writing Wave around the API-centric approach is the only reason for me to justify doing it, since it is a new concept in many ways. API’s have been around for a long time, but API-centric frameworks are rare.

    Wave Framework only has things that I consider absolutely essential for a modern website or web service. Things like HTTP request handling, on-demand image editing, caching, logging, debugging tools, API and MVC architecture. You can develop on Wave with your everyday PHP code as long as you know what Wave expects from you from input and output, the rest is up to you. If it is best for you as someone new to PHP coding, you will have to find out yourself. Try to go through the tutorials and see how well you understand the concept and then move on from there.

    Happy coding!

  • ALLAN D says:

    Thanks Kristo,

    I got it setup (very nice documentation), and ran the setup down to step 7 and got the Hello WWW. However, there is some image thats trying to display but instead get an X.

    Also, /tools/compatibility.php says that mod_rewrite is not installed, BUT IT REALLY IS. I am using (output from phpinfo.php) php 5.4.2 (64 bit), Apache API version 20120211 (64 bit), and mod_rewrite appears in the loaded modules. Everything else says Ok.

    So, not sure why the image will not display nor why it says mod_rewrite will not work. Also I get no output if configure the config.ini to use anything for system-root=, so I left it blank.

    I am not sure what you mean by API Concentric, but I am also thinking its going to be just fine for web backend stuff, getting, setting data.

    Thank you,
    Allan

  • Kristo Vaher says:

    Sorry to hear that you still have a problem, Allan.

    It seems that both of your problems (the image X as well as compatibility script warning) are actually from the fact that something is wrong with mod_rewrite. Did you try this on localhost or uploaded it to a server? Can you make sure that you uploaded these files too:

    /.htaccess
    /tools/.htaccess

    Sometimes these files may be hidden or not uploaded due to their weird format. These files are the Apache directives that web server should use locally. What Compatibility script does is that it attempts to detect a variable rewritten with mod_rewrite and if not found, it throws the warning that it does not work. So either the .htaccess is missing from those folders, or something is wrong with Apache configuration. There is some information about this here: http://www.tildemark.com/enable-htaccess-on-apache/ (thank you for asking me about it, I should definitely mention it in my documentation).

    And your API-centric question is actually answered here (the second question): http://www.waveframework.com/wave/doc/pages/faq.htm

    Let me know if you still have troubles. I’ll do my best to help.

  • ALLAN D says:

    I changed Apache httpd.conf to turn on htaccess as follows.
    AllowOverride All
    It now works. HOWEVER, I am not sure that routing everything thru the gateway index is what I want. For example, the reason I am fron ending my apache servers with nginx is because nginx is darn fast at handeling images and non php content. All of the .php stuff is forwarded to apache so the application server can do its work. Apache is not good at graphics and static content as nginx is.

    Is is necessary to use the index.php gateway? I do not want to defeat my performance gain by using nginx proxy.

    Please help me understand this.

    Thanks,
    Allan

  • Kristo Vaher says:

    The reason why routing everything through Index Gateway is useful is because you can tie all the requests and validations and cache controls to PHP itself. This is however not required, especially if you run a static-files system and do not wish to use some of the on-demand file request functionality that Wave Framework offers (such as on-demand image editing (like the resize on the test home page) and unified javascript/css requests that reduce the amount of HTTP requests).

    You can write different Rewrite rules and only redirect non-files to PHP if you want. It is not required for Wave Framework to serve resource files through PHP. But I don’t have an example of how to do this with Nginx, you technically need to edit your Rewrite regular expression to not apply for any static files that exist on the server. Note that technically it is still possible to route requests through PHP and still use proxy, since Wave Framework returns files with cache headers and proxies can technically cache this content. But setting the system up to work this way can be a little complicated and sadly I don’t have an example of how to do this right now.

    But if you intend to serve all static files (CSS, JPG, JS etc) through a proxy, then you should look at the View Controller that renders the default HTML template and remove the sections where it unifies the resources to a single request. Otherwise it would throw 404 Not Found messages.

  • ALLAN D says:

    I appologize, when I said it works, I mean that the tools/compatibility returned success on apache rewrite. HOWEVER, when running the test to see hello, I get Hello Wave but still no shiny picture:(

  • ALLAN D says:

    Kristo,
    that last paragraph was a mouthful, and I am not sure what you mean. What I can tell you is that I already have my nginx proxy setup to forward only the php code to apache, and the proxy handeles everything else. I can see that in the nginx logs.

    Now in the last statement are you talking about /controllers/controler.view.php? what do you mean unifies into single request? line numbers?

    Thanks for your patience.
    Allan

  • Kristo Vaher says:

    I apologize if my reply did not seem clear. And don’t worry about my patience, I will help you as much as possible.

    First of all, about your image problem:

    You said that you are already using Nginx to serve static resources, correct? Well in that case the image fails because that image actually does not exist. The requested URL is ‘resources/images/160×160&logo.png’ and the actual picture is ‘/resources/images/logo.png’. If pictures are served through Wave Framework, then you can use on-demand image editing functionality. In that example, the ’160×160′ is added, which means that the image will be resized by Wave Framework to 160×160 resolution. You can read more about it in ‘Dynamic Loading of Images’ documentation page. If Wave Framework does not serve that request itself and Nginx does it instead, then you cannot use this feature of Wave Framework.

    But you can still use the Framework, you just have to remember that this advanced image loading is not possible this way. Same applies to resource loading, you are likely also getting a 404 for ‘resources/jquery.js&script.js’ JavaScript file, which is actually a unified resource of ‘resources/script.js’ and ‘resources/jquery.js’ files.

    It is entirely possible to serve static files with a proxy rather than Wave Framework itself, this will indeed make your system faster. This on-demand editing and request functionality is added entirely optionally. It has multiple benefits, but of course the drawback is that PHP is serving those images. It is technically possible to make proxy cache those resources, even if they are dynamically loaded, but sadly I don’t have an example of how to configure an Nginx or Apache server to work this way.

  • ALLAN D says:

    Kristo, Thank you for your reply.

    This sounds like you have really thought about advanced image rendering, etc. But for me in general, and most web and mobile users, speed and responsiveness are key factor for success.

    For this reason, I will opt to let the api controllers serve api code.

    above you said…
    Same applies to resource loading, you are likely also getting a 404 for resources/jquery.js&script.js JavaScript file, which is actually a unified resource of ‘resources/script.js’ and ‘resources/jquery.js’ files.

    but when I ran the sample from the root as per the install documentation, I did not get a 404. Does this mean it worked?

    So with all of this said, am I to understand that my plan for letting the proxy handle static stuff (non php) is ok, and that I would need to modify some code to let it happen that way?

    What code do I modify? an engine? a controller? controllerview.php? what would I remove from controllerview.php? Is this one of the files I would manage?

    Yes It seems I am 20 questions I know, but I am a very quick learner and just need to be pointed in the right direction.

    My next step is to read the documentation fully. I have already looked at the code examples.

    Thanks,
    Allan

  • Kristo Vaher says:

    “This sounds like you have really thought about advanced image rendering, etc. But for me in general, and most web and mobile users, speed and responsiveness are key factor for success.”

    Since it is possible to make proxies work without losing that functionality – though it takes some advanced configuration to make it happen – I am not too worried about it. On-demand image and resource loading can be very useful for a modern web system and I am using it in my startup projects to great effect. For example, you never have to upload a file and then cast billion different resizing and coloring tweaks on it and save the edited copy since you can just load the copy from a URL alone. Or that users can load their avatar pictures that will be made small 60×60 and black and white automatically without you having to generate such a version yourself for every user. And when your designer changes their mind and you want colored avatars, then just changing the file request will be enough to make everything work with no need to regenerate the entire user avatar folder. But of course some systems are better off without using this and can serve files directly from a proxy instead.

    “Same applies to resource loading, you are likely also getting a 404 for resources/jquery.js&script.js JavaScript file, which is actually a unified resource of ‘resources/script.js’ and ‘resources/jquery.js’ files.” If you request the file itself from a URL (like when you view the source of the page), does the content get shown? If yes then maybe your Nginx does not serve *.js files directly and only serves images?

    “So with all of this said, am I to understand that my plan for letting the proxy handle static stuff (non php) is ok, and that I would need to modify some code to let it happen that way?”

    Yes it is perfectly fine. And the only code you would need to modify is the View Controller in /controllers/controller.view.php that builds a single unified request string for JavaScript (if you will let Nginx also serve JavaScript, then they would also start throwing a 404 Not Found messages). Basically the part where the code implodes resource filenames and checks for JavaScript files.

    Wave Framework Index Gateway uses different handlers based on the requests that the server allows it to serve, so if you decide not to allow Wave serve some requests, then that is perfectly fine. You can only redirect regular URL’s and *.api (this is needed for HTTP API) requests to Wave Framework.

    “Yes It seems I am 20 questions I know, but I am a very quick learner and just need to be pointed in the right direction.”

    It’s perfectly fine, I have learned a lot from you myself already, since you made me think about some things I had not considered before.

  • ALLAN D says:

    Kristo,

    I see your point about graphic resizing and so on. I will have to chew on that one fr a while to see if I want to use it.

    However, now after all this talk I am feeling really stupid. The reason is that when I turned on (loaded) apache rewrite module, the tools/compatibility.php scrip ran fine indicating everything was ok including the rewrite module.

    BUT…
    you keep refering to both the unified javascript and the unified graphic, but in my case neither of these exist in resources.

    resources/jquery.js&script.js
    and the image…

    It appears that the invisible .htaccess files are in place and that unified stuff should work since the
    RewriteRule !^(.*)\.php$ ./index.php [QSA,L]
    for the gateway.php is in place.

    Why do I not have the unified image and the combined .js file on my server after running the “hello Wave” sample progam?

    What am I doing wrong?

    Sincerely,
    Allan D

  • Kristo Vaher says:

    Are you sure that Nginx is not serving your image files? It seems like Index Gateway never gets these resource and image file requests. Your Apache directive is correct and the URL redirect seems to work, so I think that your Nginx tries to load these files itself and does not send these requests to PHP and Wave Framework Index Gateway.

  • ALLAN D says:

    Ok, I will try to understand here…

    When I look on Apache server, I do not see the unified image or resource files. I am not sure if they ever really get created or are just dynamically created. Is that what is supposed to be?

    I am certain that nginx is configured to serve the images, because that is what I wanted.

    Do I need to turn that off on nginx to let your api engine display them?

    Thanks Allan

  • Kristo Vaher says:

    If Nginx serves your image files, then yes the files are served by Nginx. And because files are served from Nginx, they never get to Index Gateway so Wave Framework cannot do dynamic editing on that image file. To be able to use dynamic image loading like the way the test home page shows, the image file needs to be routed through Index Gateway. If you do not need the functionality of dynamic image loading like that, then you can use Nginx and have the correct URL for the file instead of the one that includes parameters as is described in Documentation and in my previous comments. I hope that helps :)

    (it is technically possible to use Nginx proxy AND Index Gateway routing together so that it generates once and later on uses cache and gets a good speed benefit, but I do not know how to configure Nginx to work like that)

  • ALLAN D says:

    Thanks Kristo for your effort here to help me understand. I think for now I will leave it like I have it (nginx handeling the images, css, javascript, and let the api handle the php code.

    I think I have learned the power of the method, but also the weakness. It is too early for me to decide how to implement the available technology here. Of course I want the benefits of both speed AND photo resizing. I will have some website that allows user to upload images and I will want these to be standard sizes. I may just have to do it on the front end when they upload.

    It’s beyond this conversation, but I wish somehow had the option to dynamically decide whether nginx or php gateway should handle the image. That way it could be fast, and rendered without the cache. I will keep plodding along here, lots of reading and understanding to keep me busy.

    My real focus is sessions (stored in database) across my load balanced servers.

    I already have session handler code, but not sure where to poke it in on the api stuff. saw something commented out but that was more for access permissions, which I will also be doing.

    Bye,
    Allan

  • Kristo Vaher says:

    “I think I have learned the power of the method, but also the weakness. It is too early for me to decide how to implement the available technology here. Of course I want the benefits of both speed AND photo resizing. I will have some website that allows user to upload images and I will want these to be standard sizes. I may just have to do it on the front end when they upload.”

    It is a compromise yes. Wave Framework actually has an internal wrapper function that allows you to edit images the same way, so once you upload, you can use the same parameter string (like ’160×160′) on an image through a function and store the output image somewhere where you need. Not an ideal solution since you’d still have to ‘regenerate’ them if you make a change, but at least you could use the same tools that Wave Framework itself uses for this resizing.

    “It’s beyond this conversation, but I wish somehow had the option to dynamically decide whether nginx or php gateway should handle the image. That way it could be fast, and rendered without the cache. I will keep plodding along here, lots of reading and understanding to keep me busy.”

    I am looking into this as well. There is certainly a way to have Nginx request the image from Index Gateway if it does not have the cache, but I am unsure how to set it up like this yet. I will let you know if I find out.

    Anyways, let me know if you need anything. I suggest you contact me through e-mail if you have any further specific questions and I can perhaps help you better directly.

Leave a Reply

You must be logged in to post a comment.