Ubuntu install latest PHP7 version

Ubuntu has many outdated packages. That’s why people heavily use ‚external’ repositories. Latest version of PHP at the time of writing is 7.0 even though 7.1.2 has been released over a month ago. 7.1 has a couple of interesting features: http://php.net/manual/en/migration71.new-features.php To install this versin you will have to perform 4 steps: 1. Add repository The ppa:ondrej repo is recommended:

2. Install new PHP

[…]

Read Me

Login with ssh key

How to login to a remote host without knowing the password, but with private key? Having a private key located at the current directory:

   

Read Me

[Symfony] how to create own reusable bundle

1. Create new empty symfony project First, create new empty symfony project

This will create basic symfony project structure for you. 2. Create new bundle Auto-generate vanilla bundle with:

continue with the wizard and answer all the questions . This should also register your new bundle in the app. 3. Develop the bundle Add features to the bundle and commit all the changes. […]

Read Me

Detect fans in Skylake Z170 platform

By default, fans are not detected in most Z170 configurations. The solution is rather simple.

And then re-run sensors-detect. Many new nct6775 related sensors (fans, temperatures and voltages should be now available:   To make this module load after reboot, run:

 

Read Me

[Symfony] Register repository as service

 

Read Me

[Symfony] Query many-to-many relation

Given an Entity Class:

Let’s say you want to query for all the items watched by a user. In your Item Repository:

Repositories are handy but actually, you could also do it without one. Let’s extend Item Entity:

And add getter:

Thanks to this solution, all you need to do in the controller is:

 

Read Me

PHPUnit – how to check for exceptions

If you know your method will (or should) throw an exception under certain circumstances, you may want to write a test to assure it happens. One way is to use PHPUnit annotations:

And the other, the plain old assertion-like statement:

   

Read Me

How to sort Doctrine results with findAll()

Using findAll() it’s impossible to pass another orderby/sort parameter, because findAll definition looks like this:

Instead you can you findBy() which is more complex:

Look at the $orderBy parameter.   So now, when selecting all the records from a repository instead of:

just use:

 

Read Me

Symfony – how to add custom parameter to a service

Given a service with the following definition:

  if you want to pass through a additional parameter (for example a string), like this:

Change your service definition to:

  and then it will be available in the constructor, just like always.  

Read Me