June 19, 2017

Basic Prototype App with Symfony3

The objective of this is to build a simple route, and controller that handles this entire “application.” The components of this simple prototype are essentially a bunch of HTML pages with interaction hard-coded or baked into the twig templates. So the objective here is to build the structure such that building a new template is all that is required and the application will then pick it up. Assumptions Separately a custom controller handles exception catching and 404 errors. Everything, including authentication/authorization can be “faked” Presumably you’d hide this behind HTTP-Basic or keep local only. The Route

The Controller

How it Works Now all you need to do is build your filenames to…

March 23, 2017

Improve Symfony3 cache/logs performance by environment

Tired of the permission errors with your cache/logs in a Vagrant environment? Me too! After being mildly annoyed with having to manually delete /var/cache and /var/logs repeatedly during “local” development, I decided to brut force matters into my own hands and solve this little annoyance once and for all. Ironically, Symfony 3.3 is addressing some of this, so it may be obsolete by then, but in the meantime… What are we doing here? Define cache and logs directories for a specific environment. Wouldn’t it be awesome if we could customize these as parameters in the FrameworkBundle? Yes, yes it would! Write a simple CacheCommand that overrides the default cache:clear PARTY!!!! Customize your getCacheDir and getLogDir methods by…

March 13, 2017

API environment contextual responses with Symfony3 Subscribers for Dev vs. Non-Dev

According to the ideal 12 Factor App you want to store your configuration in the specific environment. This includes debugging, logging, and everything else your application does. When building an API, these days you want your response data to be JSON, unless you’re an XML holdout which case you’re still using XML. Regardless, while in production you want clear and concise error message responses that do not reveal too much information. However, outside of production you probably want a quick way to see at least the source file throwing the exception so you know where to begin without crawling logs for every iterative issue while in development. For this you’ll need your…