Sandbox

Featured articles on frontend and backend programming languages, tools, frameworks and libraries, as well as whatever I have been learning recently.

Sandbox / Developer / Symfony /

Symfony service/DI alias shortcuts

  • Written: 3 years ago
  • Category: Symfony
  • Comments: 0
Symfony's Dependancy Injection Container is immensely powerful, allowing one to define a class, or list of classes, that are required to setup a "service" and use it anywhere that is "Container Aware", that is, anywhere that the Service Container has access to, or has been injected into. Within your controllers or app classes, something you might need to do pretty often is get access to the Doctrine Entity Manager. This is usually done with the following...
Sandbox / Developer /

Composer memory allocation error

  • Written: 3 years ago
  • Category: Developer
  • Comments: 0
If you are in the PHP community and arn't using Composer, you are being left behind by its awesomeness. However Composer has some issues that its trying to solve as it grows. From time to time as Composer tries to work out your package dependancies it might run out of memory. This is rare, but can be annoying if you are in a hurry. Try running the following command to give PHP more memory to work with...
Sandbox / Developer / General tips /

How to enable PHP Opcache

Since PHP 5.5 Opcache is baked right in, however its disabled by default. If you're working on a shared host, then its pretty unlikely you'll be able to get this working, however if you, like me, just switched over to Digitalocean and are loving the new freedom you have to set up the server, you'll want to follow these quick tips. First you need to ssh into your server, i'll leave that up to you to figure out. Once inside you need to know where the file "opcache.so" file is situated. This file needs to be added to your 'php.ini' file and so to find it, we run the following command...
Sandbox / Developer /

Create your own jQuery (or raw JavaScript) events and trigger them whenever...

  • Written: 3 years ago
  • Category: Developer
  • Comments: 0
One of jQuery's less promoted attributes is that it allows us to bind and trigger our own custom events. Its a simple enough idea, but incredibly powerful! The reason the custom events are so powerful is that it means we can decouple our application, creating modules that only interact through the triggering of hooks/events. But what does that actually mean, well it means less long variable names to stop from accidental  or unintentional reuse;  smaller, more maintainable code; less time spent debugging; more time doing other fun stuff. To register your custom event you need something like the following...
Sandbox / Developer / General tips /

Auto include your debug functions through php.ini

You might not want to bloat your system with whatever debug functionality you need whilst its being developed. Instead you can add a line in your php.ini that will tell PHP to include a file from the local file system each time PHP runs and deals with a request. There is one caveat however, that if you're running CLI commands (command line) the file is not included. To set this run, open your php.ini file and look for something like the following...