Skip to content

Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this

In the process of upgrading a Symfony project from version 2 to version 5, I came across an issue with a MySQL table that has a number of BIGINT columns. There had been no issue previously, but after updating to the newer symfony (and doctrine components) mySQL bigint columns were empty/null in my doctrine entities.

After some investigation I came upon this section of the Doctrine manual:

For compatibility reasons this type is not converted to an integer as PHP can only represent big integer values as real integers on systems with a 64-bit architecture and would fall back to approximated float values otherwise which could lead to false assumptions in applications.


To protect symfony apps running on 32 bit systems, Doctrine maps Bigint columns to the string type, and this broke the entity definition I was using, even though my application will only be deployed on 64 bit systems. I think that for most people this is the norm.

There are a few different ways to get around this issue, including type casting from string to integer/integer to string in your getters and setters, but if you have a lot of bigint columns across tables, that probably isn't a great solution. In this article, I present the solution I implemented, which utilizes a Custom Doctrine type to override the built in Doctrine behavior.
Continue reading "Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this"

docker4lamp - A LAMP Docker development environment

I have made this project (Docker For LAMP) publically available on Github, under the MIT license.

The target user group is php developers who want or need a simple, minimal (yet very current) LAMP development environment. I want this to be friendly to new developers, and a useful alternative to localhost environments like xamp, mamp or wamp.

Ideally it offers the type of convenience and isolation of a vagrant lamp environment except with orchestrated containers. Continue reading "docker4lamp - A LAMP Docker development environment"

Symfony 5.2 and Apache 2.4

Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a number of years nginx with php-fpm was the preference for many sysadmins seeking to wring the maximum performance out of a webserver that also has to run php scripts, but there are now simple ways of configuring apache to use php-fpm while achieving comparable performance to nginx.

For example a vhost setting like this one is possible:


<VirtualHost *:80>
    SetEnv ENVIRONMENT "dev"
    <FilesMatch \.php$>
        SetHandler proxy:fcgi://php:9000
        # for Unix sockets, Apache 2.4.10 or higher
    </FilesMatch>
    # Proxy .php requests to port 9000 of the php-fpm container
    DocumentRoot /usr/local/apache2/cms/public
    ServerName cms.mydev.local
    ServerAdmin admin@mydev.local

    <Directory /usr/local/apache2/cms/public>
        DirectoryIndex index.php index.html
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
   
    # Send apache logs to stdout and stderr
    CustomLog /proc/self/fd/1 common
    ErrorLog /proc/self/fd/2
</VirtualHost>
 


Continue reading "Symfony 5.2 and Apache 2.4"

Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'

So you have a private Bitbucket Repo and you want to utilize it in your project composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "Invalid OAuth consumer provided"

Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'"

Howto serve a markdown document

Allmark is a simple self contained Markdown html renderer and server from developer Andreas Koch, that is written in Go.

You could certainly install Allmark locally, but there are numerous editors or standalone operating system specific markdown parsers you could use.

But what if you have some markdown documentation on a server, and need a quick and easy way to access that documentation? You can always just look at the raw markdown using vim, but what fun is that?

Allmark is a full markdown server, but installing a server just to read a couple of markdown documents is something very few people would want to do. If however, your server has docker installed, you can be reading your documentation in all its rendered glory in a matter of a few seconds. Here is how:

Continue reading "Howto serve a markdown document"

Vagrant Share and Ngrok

As more and more people utilize virtualization for development the need to easily and securely share your work in progress with team members or clients can be a great boost to productivity. Such a tool is also not bad when your kid wants to let his friend access that local minecraft server you are running on your workstation for him, not that I would know anything about that. There are several utilities that are available, and now a plug and play option that is available if you use vagrant.

In recent versions of Vagrant, Hashcorp has added a plugin called Vagrant-share. You can see if its installed by running

CODE:
vagrant plugin list

And you should see something like this:

CODE:
vagrant-share (1.1.9, system)

Continue reading "Vagrant Share and Ngrok"