Krzych Jończyk

Modern PHP, soft skills, productivity and time management.

Adding a new Logger to Laravel

tl;dr

If you want to add a new logger to Laravel just create new service extending Logger, inject it via the constructor and you’re good to go!


I’m a Symfony guy, but from some time I have to use Laravel. There is the neverending war between those, but what do. It’s not that bad eventually…

Recently I was supposed to add logs to some command, for debugging purpose. Laravel has its logger as facade but I didn’t want to use this one, I just wanted to log some data to separate log file, debug the command and delete the log. And there is no way I found to create a separate log by using the Log facade.

As it turns out, Laravel’s log facade uses monolog, so there is a possibility to access monolog itself and create a new logger. I’ve searched the web for the best solution, some suggest creating a new facade and using it, some suggests creating logger “in place” and use it only in my command. But none of it seems right
Continue reading

I’m podcast addicted. I listen to them a couple of hours every week, mostly during the tram ride to work.

It’s hard to tell how much it gives me and how much I learned, but I let the numbers speak for themselves (today is 20th October 2017 for the record, so it’s 549 days).

To learn more see my previous post about Podcasts.

[Edit] How to deploy Symfony app with Capistrano 3 on cheap OVH VPS

tl;dr

If you want to deploy Symfony app using Capistrano 3 to cheap OVH VPS then you’ll need to write a simple task to set proper permissions.

Edit: unfortunately, there was still a little problem with permissions and I made deployment semi-automatic.


I have a very cheap VPS in OVH, it costs only about $2 per month. It is perfect for my needs, I have my blog there, I have my friend’s blog as well. And now I want to move my wife’s portfolio from (even cheaper :P) shared hosting to this VPS.

Until now deploy to shared hosting looked like this:

  1. open FTP
  2. go to portfolio directory
  3. move changed files
  4. app/console cache:clear

Nightmare.

Fortunately, I had access to SSH on my hosting (not popular thing) so I could try to automate this process a little bit. But because I already have VPS then the better idea was to move the portfolio there and use some tool for deployment.

The portfolio is written using Symfony 2 framework so the best idea is to use Capistrano. I had some experience with Capifony which is pretty old, unmaintained customization for Capistrano 2 (which is also quite old). I don’t want to use old stuff. So the goal is easy: deploy Symfony 2 app using Capistrano 3 to OVH, cheap VPS.
Continue reading

Symfony

Another contribution to Symfony merged! \o/

My Pull Request has been accepted by Symfony docs guy and will be merged soon. This is a minor change, but I think it’s a good idea to improve anything we see that can be improved.

This particular change was created because I’ve seen at least 3 programmers getting parameters in service not from injection but from the container. Hope it helps them to understand how to use parameters in a good way 🙂

PR can be seen here: https://github.com/symfony/symfony-docs/pull/8399

Feels good 😎

How to make cool progressbar in Symfony command?

If you’re writing commands in Symfony then you probably know the ProgressBar component. It’s useful tool showing the current state of operations and, more importantly, ETA and used memory. Cool.

If you’ll to the official ProgressBar component page then at the beginning you’ll see a very cool progress bar, with colors, icons, changing status messages, but… If you’ll look a little further you’ll see a sad, black and white progress bar, that is far from a “promise” made at the beginning 🙁

Heads up! We’ll make it like this 🙂
Continue reading

Using PHP5.6 and PHP7.1 at the same time on OS X!

I wanted to write a manual about installing PHP5.6 and PHP7.1 at the same time, on OS X, using homebrew instead of using Docker (which I find not the best idea on OS X, but maybe I’m wrong?). But someone did it before me 🙂

If you want to have many PHP versions simultaneously then follow the instructions described by Jani Tarvainen on Symfony Finland blog: https://symfony.fi/page/how-to-run-both-php-5-6-and-php-7-x-with-homebrew-on-os-x-with-php-fpm and enjoy native, fast and simple way to work on crappy old projects in PHP5.x and new, shiny ones in 7.1 😛
Continue reading

Keep your logs short with logrotate

tl;dr

If you are developing some application that writes a lot of logs use logrotate to keep them short and don’t allow them to reach gigabytes.


I’m developing in Symfony framework on daily basis. And on the development environment, it creates lots of logs. Every request is logged, every command is logged, every event subscriber is logged. And if you’re using some older version deprecations are also logged. On my computer, every refresh in browser creates over 1 MB of logs! My friend gets almost 10 MB…
Continue reading

My new addition is the Casey Neistat vlog on youtube. He is so damn positive person and his videos are so cool I literally spend hours watching them. And it’s no waste of time (well it’s way better than watching tv for sure 😉).

Check it out yourself 👉 https://www.youtube.com/user/caseyneistat

Shorties – new post format

From some time on I was thinking about some completely different format of posts, the short one. I even had a name for it – shorties. I have pretty many thoughts on my mind that I’d like to share with you, but they’re too short to make it a proper post. So the idea died.

Until now.
Continue reading

Photochooser – version 0.2.1 released!

tl;dr

I changed the application from one class to three with separated responsibilities, wrote some tests and use Travis-CI for continuous integration. Version 0.2.1 is available here.


Since the last post, the application changed a lot. When I had a little time I sat down and just coded. Changes are too small to wrote about separately, but now there are enough of them to do some summary 🙂
Continue reading

« Older posts

© 2018 Krzych Jończyk

Theme by Anders NorenUp ↑