List of Symfony2 Exceptions

Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php
Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php
Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php
Symfony/Component/Serializer/Exception/InvalidArgumentException.php
Symfony/Component/Serializer/Exception/UnsupportedException.php
Symfony/Component/Serializer/Exception/UnexpectedValueException.php
Symfony/Component/Serializer/Exception/LogicException.php
Symfony/Component/Serializer/Exception/Exception.php
Symfony/Component/Serializer/Exception/RuntimeException.php
Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php
Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php
Symfony/Component/HttpKernel/Exception/HttpException.php
Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php
Symfony/Component/HttpKernel/Exception/FlattenException.php
Symfony/Component/Form/Exception/InvalidConfigurationException.php
Symfony/Component/Form/Exception/TransformationFailedException.php
Symfony/Component/Form/Exception/PropertyAccessDeniedException.php
Symfony/Component/Form/Exception/TypeLoaderException.php
Symfony/Component/Form/Exception/NotInitializedException.php
Symfony/Component/Form/Exception/NotValidException.php
Symfony/Component/Form/Exception/AlreadyBoundException.php
Symfony/Component/Form/Exception/InvalidPropertyPathException.php
Symfony/Component/Form/Exception/CreationException.php
Symfony/Component/Form/Exception/StringCastException.php
Symfony/Component/Form/Exception/FormException.php
Symfony/Component/Form/Exception/TypeDefinitionException.php
Symfony/Component/Form/Exception/UnexpectedTypeException.php
Symfony/Component/Form/Exception/ErrorMappingException.php
Symfony/Component/Form/Exception/InvalidPropertyException.php
Symfony/Component/Process/Exception/ProcessFailedException.php
Symfony/Component/Process/Exception/RuntimeException.php
Symfony/Component/Yaml/Exception/DumpException.php
Symfony/Component/Yaml/Exception/ParseException.php
Symfony/Component/Filesystem/Exception/IOException.php
Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php
Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php
Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php
Symfony/Component/HttpFoundation/File/Exception/UploadException.php
Symfony/Component/HttpFoundation/File/Exception/FileException.php
Symfony/Component/DependencyInjection/Exception/InvalidArgumentException.php
Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php
Symfony/Component/DependencyInjection/Exception/LogicException.php
Symfony/Component/DependencyInjection/Exception/OutOfBoundsException.php
Symfony/Component/DependencyInjection/Exception/BadMethodCallException.php
Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php
Symfony/Component/DependencyInjection/Exception/RuntimeException.php
Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php
Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php
Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php
Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php
Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php
Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php
Symfony/Component/Config/Exception/FileLoaderLoadException.php
Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php
Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php
Symfony/Component/Config/Definition/Exception/UnsetKeyException.php
Symfony/Component/Config/Definition/Exception/Exception.php
Symfony/Component/Config/Definition/Exception/InvalidDefinitionException.php
Symfony/Component/Config/Definition/Exception/InvalidTypeException.php
Symfony/Component/Config/Definition/Exception/DuplicateKeyException.php
Symfony/Component/Routing/Exception/InvalidParameterException.php
Symfony/Component/Routing/Exception/ResourceNotFoundException.php
Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php
Symfony/Component/Routing/Exception/RouteNotFoundException.php
Symfony/Component/Routing/Exception/MethodNotAllowedException.php
Symfony/Component/Validator/Exception/MappingException.php
Symfony/Component/Validator/Exception/MissingOptionsException.php
Symfony/Component/Validator/Exception/GroupDefinitionException.php
Symfony/Component/Validator/Exception/ConstraintDefinitionException.php
Symfony/Component/Validator/Exception/UnexpectedTypeException.php
Symfony/Component/Validator/Exception/InvalidOptionsException.php
Symfony/Component/Validator/Exception/ValidatorException.php
Symfony/Component/Locale/Exception/MethodArgumentValueNotImplementedException.php
Symfony/Component/Locale/Exception/MethodArgumentNotImplementedException.php
Symfony/Component/Locale/Exception/MethodNotImplementedException.php
Symfony/Component/Locale/Exception/NotImplementedException.php
Symfony/Component/CssSelector/Exception/ParseException.php
Symfony/Component/Security/Core/Exception/SessionUnavailableException.php
Symfony/Component/Security/Core/Exception/AuthenticationException.php
Symfony/Component/Security/Core/Exception/UnsupportedUserException.php
Symfony/Component/Security/Core/Exception/AccessDeniedException.php
Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php
Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php
Symfony/Component/Security/Core/Exception/LogoutException.php
Symfony/Component/Security/Core/Exception/CookieTheftException.php
Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php
Symfony/Component/Security/Core/Exception/DisabledException.php
Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php
Symfony/Component/Security/Core/Exception/LockedException.php
Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php
Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php
Symfony/Component/Security/Core/Exception/TokenNotFoundException.php
Symfony/Component/Security/Core/Exception/AccountExpiredException.php
Symfony/Component/Security/Core/Exception/NonceExpiredException.php
Symfony/Component/Security/Core/Exception/AccountStatusException.php
Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php
Symfony/Component/Security/Core/Exception/BadCredentialsException.php
Symfony/Component/Security/Acl/Exception/SidNotLoadedException.php
Symfony/Component/Security/Acl/Exception/AclNotFoundException.php
Symfony/Component/Security/Acl/Exception/NotAllAclsFoundException.php
Symfony/Component/Security/Acl/Exception/InvalidDomainObjectException.php
Symfony/Component/Security/Acl/Exception/NoAceFoundException.php
Symfony/Component/Security/Acl/Exception/Exception.php
Symfony/Component/Security/Acl/Exception/ConcurrentModificationException.php
Symfony/Component/Security/Acl/Exception/AclAlreadyExistsException.php
Since most symfony2 installations also include doctrine2, below is a list of all the Doctrine 2 Exceptions.
Doctrine/Common/DataFixtures/Exception/CircularReferenceException.php
Doctrine/Common/Annotations/AnnotationException.php
Doctrine/Common/CommonException.php
Doctrine/Common/Persistence/Mapping/MappingException.php
Doctrine/ORM/TransactionRequiredException.php
Doctrine/ORM/Query/QueryException.php
Doctrine/ORM/Query/AST/ASTException.php
Doctrine/ORM/Mapping/MappingException.php
Doctrine/ORM/UnexpectedResultException.php
Doctrine/ORM/PessimisticLockException.php
Doctrine/ORM/OptimisticLockException.php
Doctrine/ORM/Internal/Hydration/HydrationException.php
Doctrine/ORM/ORMException.php
Doctrine/ORM/NonUniqueResultException.php
Doctrine/ORM/EntityNotFoundException.php
Doctrine/ORM/Tools/ToolsException.php
Doctrine/ORM/Tools/Export/ExportException.php
Doctrine/ORM/Proxy/ProxyException.php
Doctrine/ORM/NoResultException.php
Doctrine/ORM/ORMInvalidArgumentException.php
Doctrine/DBAL/Query/QueryException.php
Doctrine/DBAL/Types/ConversionException.php
Doctrine/DBAL/Schema/SchemaException.php
Doctrine/DBAL/Sharding/ShardingException.php
Doctrine/DBAL/ConnectionException.php
Doctrine/DBAL/Cache/CacheException.php
Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
Doctrine/DBAL/Driver/Mysqli/MysqliException.php
Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php
Doctrine/DBAL/DBALException.php

Perl is Dead

Someone has to call it. Perl died on May 6, 2015 at 3:23PM Eastern US time. The cause of death was neglect.

PHPUnit –log-json is Broken, Here’s How to Fix It

For some reason, PHPUnit doesn’t produce valid Json when using the –log-json command-line option.

The output looks like this.

{
    "event": "suiteStart",
    "suite": "TestAcme",
    "tests": 3
}{
    "event": "testStart",
    "suite": "TestAcme",
    "test": "TestAcme::testAcme1"
}{
    "event": "test",
    "suite": "TestAcme",
    "test": "TestAcme::testAcme2",
    "status": "pass",
    "time": 1.85778188705,
    "trace": [],
    "message": "",
    "output": "t"
}{
    "event": "testStart",
    "suite": "TestAcme",
    "test": "TestAcme::testAcme3"
}{
    "event": "test",
    "suite": "TestAcme",
    "test": "TestAcme::testAcme3",
    "status": "pass",
    "time": 12.4938511848,
    "trace": [],
    "message": "",
    "output": ""
}

That’s invalid. It should be an array of objects. So to fix this, I do this when decoding.

json_decode('[' . str_replace('}{', '},{', $json) . ']');

Here’s the bug report on this issue. Someone has proposed a command-line argument to tell phpunit to produce valid Json. Why not just fix the output so that it’s valid Json? Apparently that’s not going to happen.

How to Restart Networking on a Mac

If you’re like me and you have to connect to a VPN with the Cisco Anywhere Connect client, you’re probably dealing with strange networking issues as a result. One of the things I do when I’m experiencing networking issues is that I restart networking on my Mac.

To do that run this command.

sudo ifconfig en0 down; sudo ifconfig en0 up;

That’s actually two commands on one line, but it should work. You will need to make sure that your network interface is en0 and not en1 or something. To figure that out just run this command.

ifconfig

You should see an interface with an IP address on it, that’s the one connected to your network. If you have multiple network interfaces with IP addresses, you’ll just have to figure out which one you want to restart and use it.

If you’re still having issue, try flushing your routing table information.

Symfony 2: Generate URL with Full Hostname and Colon and Slashes

Screen Shot 2015-03-05 at 2.09.48 PMSir Tim Berners-Lee has apologized for all of the slashes in the http:// world. But slashes and colons we must have to create a valid web address, and with SSL, we need to know whether it’s http:// or https://.

Fortunately those of us programmers old enough and wise enough to use a wonderful framework like Symfony, generating a valid web address in our source code is easy.

When generating a URL in Symfony, make sure the third parameter for generateUrl is set to TRUE.

$this->generateUrl('name_of_route', array(), true);

As Petar’s comment below says, in Symfony 3, it’s a bit different.

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

$this->generateUrl('name_of_route', array(), UrlGeneratorInterface::ABSOLUTE_URL);

That’s a bit cleaner in version 3, and, more readable.

But you folks out there still rolling all of your own custom PHP, I’m sure you can build a valid URL by pulling data out of the $_SERVER hash. If you are one of these sorts of programmers, you should read my post Stop Building Shitty PHP Web Applications.

Screen shot 2015-11-22 at 8.53.10 PM

[]: http://amzn.to/1IkpcFq

Stop building shitty PHP web applications

I’m sort of active on Stackoverflow.com and I see so many stupid questions from people who know nothing about PHP trying to cobble together a pile of shit web application.

I admit that nearly 20 years ago when I started working with PHP, I wrote some awful code, just wretched shit. But back then, everyone was writing shitty web apps, there were no frameworks and templating systems didn’t exist.

And so in 2015, when I see people posting questions on Stackoverflow with table-based layout and PHP mingled in with their presentation, no templates, and just disgusting application design, I just have to shake my head.

I refuse to answer the questioner’s specific question because doing so would only enable them to continue working on their poorly designed application. What I do is I try to steer them towards using a templating system like Twig, or even better a framework like Symfony.

The problems with these old ways of PHP programming where everything is a jumbled mess are many. First of all, as a programmer, you have to work way too hard to get anything resembling a functional application out of that mess you’ve created. Secondly, even if you did end up with something that worked, good luck maintaining and keeping the bugs at bay.

So before you start programming, don’t work so hard, get a framework and learn how to properly separate your presentation, code and database because mixing all that up is a bad idea and will lead to bad software and a bad user experience. Research the model, view, controller design paradigm. It works.

Google Fonts Generates Invalid HTML

Screen shot 2014-11-22 at 10.33.11 AM So if you go to Google Fonts and pick a couple of funky fonts for your next super funky web app, you might get something that looks like this from Google.

<link href='http://fonts.googleapis.com/css?family=PT+Sans|Anton' rel='stylesheet' type='text/css' />

That’s what Google tells you to use in your markup to access those fonts. It technically works, but if you stick that in your head and try to validate your HTML with the W3C validator, you’ll get an error that looks like this.

Bad value http://fonts.googleapis.com/css?family=PT+Sans|Anton for attribute href on element link: Illegal character in query: not a URL code point.

The issues are related to that plus-sign and vertical bar. What you need to do is this.

<link href='http://fonts.googleapis.com/css?family=PT%20Sans%7CAnton' rel='stylesheet' type='text/css' />

You can find URL encoding characters here.

Online Police Scanner

Screen shot 2014-11-21 at 8.19.22 PM In my spare time, I’m a geek about information and government transparency. I foolishly believe that technology can and will make government agencies more transparent, subject agencies to criticism and make government better.

To further that agenda, I created this online police scanner for my hometown of Montpelier, Vermont.

The technology to make this work is pretty out-of-the-box.

The hardware is just a Uniden BC72XLT handheld scanner and a Asus mini laptop. I’m not even using a mixer, I’m just running my audio out from my scanner straight into the laptop’s audio in.

So on the software side, I’m using Sox to capture the audio and save it as an Ogg Vorbis file.

Because the audio coming in is so crappy, I am running a lowpass filter on it when I’m capturing it.

I think the quality of the audio is pretty good considering the source.

I’m recording the audio in 10-minute segments. Once a segment is done, it gets uploaded to the server and available to listen to.

In terms of how much code I’ve written to make all of this work, it’s less than 100 lines. There is a bit more sophistication that can and will be added, but the amount of custom code will likely never exceed 1,000 lines.

And the reason I built this system isn’t because I care that much about listening to the Montpelier police scanner any where in the world, it’s because I think this technology could be really useful for low-budget broadcasting of audio and video.

One really annoying thing I discovered building this system is that Apple’s Safari browser doesn’t support the Ogg Vorbis format. So in order to make this work with Safari, I would need to either not use the open Ogg format, but rather some sort of proprietary format like MP3, or I would need to create two versions of the audio. It’s just hilarious how much of a hissy fit Steve Jobs threw about Flash, yet his own browser doesn’t support the open data formats.

Unfortunately, disk space is an issue for me, so I chose to only distribute the audio as Ogg. That means Safari and Internet Explorer users are out of the luck. But frankly, both of those browser’s are second-class citizens on the web now anyways. Just download Chrome, and if you hate Google, get Firefox.