Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Automatic Asset Optimization with Munee
Oct 12, 2015 @ 15:26:42

The SitePoint PHP blog has posted a tutorial showing you how to optimize how your application works with assets with Munee.

Munee is a n asset management tool which can compile LESS, SCSS, or CoffeeScript, manipulate images, minify CSS and JS, and cache assets on the server and client on the fly. It works with PHP 5.3 and newer versions.

In this tutorial, we will learn how Munee makes it easy to include assets in templates, how to install it, how it works and how to use it. Munee is another way to avoid NodeJS in asset management of PHP apps.

He starts the article with a few reasons why you'd want to use Munee to manage your application's assets including automatic minification and both server and client side cache handling. He covers a bit about how it works and what it does to cache assets via simple HTTP headers. He then gets into the actual installation of the tool, the code needed to run it in your system (a one-line call) and how to have the server rewrite all the requests back to the waiting PHP file. He shows how to compile different asset types including SCSS, LESS and CoffeScript files as well as minifying Javascript and CSS. Munee also includes an on-the-fly image resize handler that will also cache the results. Finally he talks about how you can use it to combine assets and briefly about the API the library provides for some other functionality.

tagged: asset optimization munee tutorial css javascript less scss coffeescript cache

Link: http://www.sitepoint.com/automatic-asset-optimization-with-munee/

Stefan Koopmanschap:
Want to Be More Productive? Work Less!
May 22, 2014 @ 15:02:08

Stefan Koopmanschap has a recommendation for all of the developers (really, anyone) out there about their work habits - want to be more productive? Work less.

There are many people (myself included for a long time) that will work more and more when they have more stress. Whether it’s a deadline or simply too much work on your hands, you just start working longer, open your laptop when at home just to finish that one feature, skip lunch or ignore your RSI-breaks. While this may sometimes work, in the long run, this will only make you less productive.

He talks about a few things that can come with "more work" that can make you less productive in the long run. He includes a few recommendations to help "take back that productivity" including:

  • Take breaks
  • Take regular days off
  • Holidays are good
  • Don't always work from the office
  • Do "fun" work

He also points out that a lot of your level of productivity revolves around stress and how even just changing small things like where you're working from can make a real difference.

tagged: productivity less stress opinion recommendation breaks

Link: http://leftontheweb.com/blog/2014/05/21/Want_To_Be_More_Productive_Work_Less

SitePoint PHP Blog:
Getting Started with Assetic
Apr 14, 2014 @ 15:37:00

The SitePoint PHP blog has a new post from Lukas White today looking at the Assetic asset management library and how you can get started using it in your application.

There was a time when asset management meant little more than inserting a <link> tag or two and a couple of <script> tags into your HTML. Nowadays, though, that approach just won’t cut it. There’s performance, for one thing. [...] Also, as client-side applications have become more and more sophisticated, managing dependencies amongst scripts and libraries has become increasingly complex. Furthermore, technologies such as Less, Compass and Coffeescript require assets to be compiled, adding yet another step to the process of managing assets. In this article I’m going to look at a PHP package called Assetic which helps manage, compile and optimize assets such as scripts, stylesheets and images.

He briefly discusses asset management first, just to get everyone on the same page as far as what "assets" are and some considerations about their use. Next is an introduction to the Assetic library itself and the install/usage of a simple "AssetCollection" object. He also shows how to add assets to the object and how to configure compression and generation of the files (like with LESS). He also shows how to use the AssetManager and FilterManager object types along with the AssetFactory handler. Finally, he talks about some of the sample output and caching the tool can do with file-based cache handling.

tagged: assetic introduction asset tutorial javascript css less compress

Link: http://www.sitepoint.com/getting-started-assetic

Gary Hockin:
Less is More
Apr 07, 2014 @ 14:56:36

Gary Hockin has a new post to his site talking about how he's found that less is more when it comes to what to include in your "composer.json". He works through some of his own opinions on the matter and suggests a bit more thought before just including another library.

I have absolutely no doubt this post will be largely disagreed upon by many in the PHP community, but I’ve had a terrible day and I’m hoping that the process of just getting this off my chest will be therapeutic in some way. [...] So, today I sat down and started writing the tests for our new lightweight SDK that offsets much of the work needed in the delivery of the adverts to workers via a Beanstalk queue. It should have been so easy. Things went well for the early part until I realised that I wanted to be able to extract and serialise our Device object to put it into the queue, and then hydrate it back into a Device object inside the worker

He assumed that since he'd used Zend Framework 2 a good bit and there were no (declared) dependencies, he could directly use an individual component. Unfortunately, there was a dependency (ZendFilterChain), requiring another package to be added via Composer and pulled down. He points out that Composer has made this almost too easy and developers maybe aren't as thoughtful about the libraries they pull in because of it.

He makes a call out to developers to remember the idea behind the MicroPHP Manifesto and really think about the code they're puling in, how large it is and if it's what they really need. He's not suggesting that Composer is the problem, rather the blind usage of it without thinking through the implications.

tagged: less more library composer packagist include

Link: http://blog.hock.in/2014/04/05/less-is-more

NetTuts.com:
Building Ribbit in PHP
Jan 04, 2013 @ 16:22:48

In the first part of a new series on NetTuts.com, they started on the creation of a full web application (a Twitter clone). The first article covered the CSS and using LESS to create an interface. In this second post they get into the PHP backend, opting to create it without a framework on the first shot.

In the initial entry in this series, we took care of the UI-aspect of our Twitter-clone, called Ribbit. Now, we’ll begin coding the application in a number of languages. This lesson will leverage standard PHP (with homegrown MVC), but, in future articles, we’ll review other implementations, such as with Rails or Laravel.

They provide all the code you'll need, the database table structure to power it (MySQL) and the examples of a model, router and basic MVC stack to handle the requests. They help you make a user creation and login system as well as a few other pages ("buddies", "make a post" and a few others). You can also download the source from their Github account if you want it all in one shot.

tagged: ribbit backend tutorial series css less mvc

Link:

ScreenFony.com:
Work with bootstrap, assetic and less
Sep 25, 2012 @ 15:36:20

On the ScreenFony.com site there's a quick tutorial showing you how to get started with Symfony2+Twitter Bootstrap+Assetic+LESS in a basic application. Assetic is a library that helps with asset management and use and LESS is a CSS pre-processor that makes it simpler to work with your site's CSS.

Bootstrap is a well known and powerful front-end framework for fast prototyping, it uses LESS and it can be easily integrate in your Symfony applications with the help of assetic. In this post I’ll show how to: Install bootstrap in you Symfony application, load it using assetic, and compile bootstrap LESS files with lessphp.

Using Composer, creating a new Symfony2 project is just a single command away. The just update the "composer.json" and run the install to get the other needed libraries (LESS and the Twitter Bootstrap). They help you set up some Assetic filters for LESS and provide a simple page to output the Bootstrap in your header.

tagged: symfony2 assetic twitter bootstrap less css tutorial composer

Link:

ServerGrove Blog:
Error "Cannot find module 'less'" with Symfony2, Assetic and Twitter Bootstrap
Mar 19, 2012 @ 17:36:25

On the ServerGrove blog, there's a quick post with a handy tip for the Symfony2 + Assetic users out there - how to get it to recognize the "less" module.

Unfortunately the Symfony documentation does not provide any details on how to configure Assetic to use LESS. There is a blog post by Dustin Dobervich that gives some pointers, but after following the instructions, Assetic issued the following error: Cannot find module ‘less’. We searched around without much success. After several tries, we nailed the configuration.

It's an easy two-step process: first you be sure you have "npm" (the package manager) installed on your system, then you modify your Symfony app.yml file to point to the Node modules path.

tagged: twitter bootstrap module less css yml setting node module

Link:

Ibuildings techPortal:
lessphp: PHP implementation of Less CSS
Dec 17, 2010 @ 15:49:54

On the Ibuildings techPortal today there's a new tutorial from Robert Raszczynski with his look at the lessphp project - a native PHP implementation of the LESS CSS framework.

In a nutshell, Less CSS is a tool that lets you simplify your CSS style sheet and allows you to extend limited CSS functionality by introducing variables, mixins, operations and nested rules. The original implementation is written in Ruby; however, there is a PHP solution based on LESS CSS called lessphp.

He mentions the good and the bad about using LESS - it can speed up your CSS development time by making it more familiar but it also comes with the caveat that the CSS files have to be generated each time an update is made. He covers some of the basic features of lessphp including variables, mixins, nested rules, operations (improving on already defined rules) and being able to use multiple .less files. He includes a XML snippet that can be dropped into your Ant (or Phing) build to run the generation at deployment time.

tagged: lessphp less css framework tutorial features

Link:

NETTUTS.com:
How to Squeeze the Most out of LESS
Oct 29, 2010 @ 15:18:50

On the NETTUTS.com site today there's a new tutorial about using the LESS CSS tool to get the most out of the styling of your website. The tutorial uses the PHP implementation by Leaf Corcoran to accomplish the same things as the Ruby library offers.

During a sick day a few weeks ago, I got around to something I’ve been meaning to look at for about a year: LESS. If anything web technology is worth a look, I promise LESS is. In this article, we’ll look at the amazing power of LESS and its ability to streamline and improve your development process. We’ll cover rapid prototyping, building a lightweight grid system, and using CSS3 with LESS.

They use an output buffering trick to handle parsing and executing the ".less" CSS-based files through the library and spit the parsed version back out the other side. There's plenty of examples of how to use the LESS syntax ending up in their previously mentioned grid system using mixins, some cross-browser CSS3 and the CSS3 Pie tool.

tagged: less css tutorial csspie stylesheet

Link:

php|architect Blog:
Less Code isn’t Always Better
May 03, 2010 @ 18:16:59

On the php|architect blog Keith Casey has a new post that suggests something a bit counterintuitive to what a lot of developers think about their code - less code isn't always better.

Everyone says “I could build that in an afternoon/weekend/marathon session of caffeine-fueled code-debauchery” but to actually do something well, unsurprisingly, it usually takes longer.

He gives an example of this forum script that's under 1KB of code (949 bytes or so) and has some of the basic features of any forum software out there. Keith talks about the software - the features included, the included security, how it uses quotes to its advantage and how it only uses the basic functionality of PHP to make it all work.

Keith also includes a few criticisms of the code like how it uses short tags, the lack of linebreaks, using $_REQUEST and a few more.

To be blunt, it’s not pretty and doesn’t have many features, but honestly, I fluctuate between terrified and impressed by the feat. [...] More than anything, it’s refreshing and fascinating to see what someone can do when they set clear, simple, direct priorities and focus exclusively on those.
tagged: less code opinion forum example

Link:


Trending Topics: