Overwrite vendor classes

In composer.json, under [„autoload”][„psr-4”], add an entry with namespace as the key and path as the value:

  Copy files you want to override under that path (keeping sub-namespace directory structure) and edit them there. They will be picked in preference to the library package’s original „classpath”. It would seem that namespace->path mappings added to composer.json in this manner are considered before those added […]

Read Me

composer killed while updating

The „Killed” message usually means your process consumed too much memory, so you may simply need to add more memory to your system if possible. Actually, you should increase the amount of memory PHP is using by editing /etc/php.ini and adjusting

Change 1024MB to match your requirements.

Read Me

Convert array to object in PHP

 

Read Me

Convert complex PHP object to string

Easiest and probably the fastest way is to execute:

 

Read Me

How To Dynamically Invoke A Class Method with a Prefix In PHP

Simple:

which is equivalent to:

 

Read Me

How to remove BOM from CSV file with PHP

 

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

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

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

PHP script removing bidding products from CENEO

Simple php-cli script to remove bidding products from CENEO, using CENEO API. Script prepared for a Magento shop. Ceneo.xml is a products map that looks like this:

Here’s the script:

 

Read Me

My vagrant devbox

A little update to my vagrant-devbox: added MySQL installation script, added support for Xdebug   Here’s the project: https://bitbucket.org/QWERTY_/vagrant-devbox Tested in Ubuntu 16.04.

Read Me Leave comment

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

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

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