Current project entering new fase

Upgraded to Laravel 5.2.  Moderation, management, security are now all implemented on top of the basic functionality. Performance looks good. Now adding Facebook and Twitter integration. Look and feel of the HTML views are done. Next step; the iOS part. The framework is prepared to spit out json data, so the app will just be a frontend with some content adding facilities. As I will be writing the iOS stuff, I will also document the json output so it will become a fully documented API. Than we can outsource the Android part …

questionmarkHint 😉

Laravel/blade ajax architecture

The current project has an architecture which uses a plain laravel/blade template approach. In the future we want to replace this approach by a total ajax/json approach to reduce server load and use the web application the same as a mobile client/app.

Now for the first release of our curren t project we are switching to an intermediate approach in which we are going to use a starting blade template which is going to use ajax calls to load the content/pages. This has a lot of benefits regarding managing server load/http requests, but it does require some extra coding.

Another drawback is that forward/backward buttons and direct urls functionality is lost. However, by utilising pushState & popState javascript functions we can solve this.

 

 

Laravel pagination and Nginx

So we are still benefitting the completeness of the Laravel framework and started using the Pagination functions of Laravel. Which is absurdly easy except for a slight hiccup which needed some configuration of the web server.

Since Laravel captures all url requests and captures the

/?page=

parameter to do its magic, this parameter must be accepted by Nginx as part of the request. By default the ubuntu Nginx implementation we use actually has the following configured for the server

try_files $uri $uri/ index.php$query_string;

, this results in a 404 error when using larval pagination. So to get it working just use

try_files $uri $uri/ index.php?$query_string;

in the Nginx server configuration (watch the question mark) and you can enjoy the pleasure of using Laravels pagination implementation.

Implementing date/time functions

Since our current project will need to be available in multiple countries we needed to tackle the timezone challenge. However this proved to be really easy by using this great javascript code Momentsjs . It will convert almost anything you throw at it into some readable form. So the solution was to set the server in the UTC timezone and convert it to the users timezone at the client side via Momentjs, This way the date/time is displayed in the timezone set at the client side.

Now to make things even a bit more user friendly, Momentjs is able to convert it localised to “time from x”. So by using this command: moment.utc(utc_date).local().fromNow() , we got a really nice “x time ago” text for the date. In which time is displayed in seconds, hours, days etc.

Changed Javascript modal function

Until now we relied on Magnific Popup for our modal functions in the current project. And although it is a very nice modal solution it was overkill for our current project. In this project we really like to build and finetune the interface, and control all the aspects of it. So we changed to the far more basic but especially suited for our needs to the query-modal which fits this project.

 

Upgraded to Laravel 5.1 LTS

So now we can look to the future 🙂 The Laravel Long Term Support (LTS) release is here and we are going to build on that great foundation.  fiveone

It took about 40 minutes to upgrade from 5.0 with just a few hick-ups due to my own little knowledge of the framework.

It still amazes me how much I can do without having any in-depth knowledge of the framework. And I still feel comfortable with the security and stability of the application I am writing. Performance we shall solve through hardware 😉 Just kidding.

Javascript in Blade

Have been building the project with the blade templates and javascript combined. By using conditional arguments in blade you can easily control which arguments and JS commands get combined in the final response. Easy to get everything centralized around a typical response, but….

blade_js

 

This does make a blade template unreadable, you get a combination of HTML, Blade and JS (maybe even some CSS). So now we moved the JS code to functions in a seperate JS file, and it really cleans up. Just a few function calls is all the javascript that is left in the blade templates.

 

Application Stack

This is an overview of the application stack I am using for the development of the next project. It is a first time for me for a lot of components in this stack. Although over the years I have touch many of these technologies, they haven’t been standing still.applicationstack

So CSS, Javascript and even MySQL all have changed a lot. For Laravel, which is at the core of this project, it has been totally new for me. I love it, a framework that helps instead of forces you to comply. Although I adopt the MVC design, it can be useful for the progress of the project to take some shortcuts now and then ;).