How to monitor disk activity

How to monitor disk activity under Linux?

if you don’t have it yet:

  Or use

  from sysstat package/

Read Me

How to remove BOM from CSV file with PHP

 

Read Me

Handy commands to show differences between branches in GIT

Handy commands to show differences between branches in GIT:

 

Read Me

Ubuntu failes to sync time

In case local time is not being synchronized with a NTP server and:

returns something like:

The ‚conditionFile is executable’ line means there’s a unfulfilled dependency and /usr/sbin/VboxService file is blocking timesync. We can check what package the file belongs to by running:

As you can see, this file is needed so I will just remove the executable flag and try to restart […]

Read Me

How to disable all form elements without JS

Easy, just place all the elements you want to be disabled inside a <fieldset> like this:  

And that’s it!

Read Me

Mysql error ‚Row size too large’

Error: „Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.”   Solution: Change your DB structure so that it fits in the InnoDb limits.   Quick fix: Add the following to the my.cnf file under [mysqld] section.

And then execute: ALTER TABLE mdl_lti ROW_FORMAT=Compressed;   […]

Read Me

Dependency injection container

Recently, for a project I’ve been working on, I had to choose a container bundle that will do the dirty job. The solution is not using any ‚framework’ , so to keep things simple, one of the obvious choice was Pimple: http://pimple.sensiolabs.org/ Although developed in sensiolabs (the same guys behind Symfony) I had a feeling it’s not really what I need… I started researching and trying it on […]

Read Me

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

[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

[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

Symfony3 – redirect to the previous location

I encountered the following problem: Given an action deleteAction in a controller I have to redirect to the previous location. Normally this information would be stored in the request headers as the referrer address. It’s tempting to write this:

but you’ll have to repeat yourself everytime you do a redirect. That’s why I decided to move this code to a service:

The requestStack gets injected by Symfony via […]

Read Me

HOW TO install Xdebug, php7, vagrant and Sublime3

I hate to install and configure it but overall it’s a great tool and a necessary one if you want to take debugging to the next level. To stop var_dump-debugging you are going to need: A machine with IDE or PHP editor installed A server featuring Apache and PHP Xdebug package My configuration script Test it all Let’s do it step by step. 1. Preparing PHP editor […]

Read Me Leave comment

Vagrant cheatsheet

Found a nice vagrant command line listing: http://howtoprogram.xyz/2016/07/11/basic-vagrant-commands/

Read Me Leave comment

Prosty box vagrant

Mój prosty config pod VirtualBox przygotowany z użyciem Ansible. Można go pobrać stąd: https://bitbucket.org/QWERTY_/vagrant-devbox Maszyna wirtualna zbudowana jest na bazie Ubuntu 16.04 z zainstalowany PHP7 oraz MySQL.    

Read Me Leave comment

PuPHPet

PuPHPet

Bardzo ciekawe narzędzie do wstępnej konfiguracji maszyny wirtualnej dla vagranta działającej np. w VirtualBox: https://puphpet.com Niestety, to już moja kolejna nieudana próba. Za każdym praktycznie razem coś nie funkcjonuje jak powinno. Tym razem nawet na domyślnych ustawieniach maszyna gościa nie ma zainstalowanego serwera www i bazy danych. Zostaję jednak przy ręcznej konfiguracji hostów za pomocą Vagrantfile i ansible 🙂

Read Me Leave comment

Instalacja SublimeLinter

Instalacja SublimeLinter

Linter jest pakietem, który sprawdza kod pod kątem błędów „stylistycznych”. Linter jest dostępny dla większości języków, ja akurat skupię się na pluginie obsługującym PHP. Zależnością wymaganą do instalacji SublimeLinter-php jest pakiet SublimeLinter3. Oba instaluje się w podobny sposób, za pomocą managera pakietów:

wpisując nazwę pakietów: Po instalacji pokaże się ekran „powitalny” z instrukcją itd. itp. Następnie zalecane jest przeładowanie Sublime. Warto rzucić okiem na […]

Read Me Leave comment

Kohana – kopiowanie obiektów

Kohana – kopiowanie obiektów

Kopiowanie obiektów z istniejącego do nowego oraz zapisanie go do bazy danych rozwiązałem w następujący szybki sposób:

Jeśli istnieją atrybuty, które należy zmienić lub usunąć, można zapisać: unset( $new_object -> id ); A następnie ustawić je na odpowiednie wartości:

 

Read Me Leave comment