CakePHP Time formatting: year of "week of year"

While jumping between PHP and JavaScript - one of the most annoying things is dates handling. Recently, one of the clients reported that, while using our app for appointments and work schedule - they lost one of the working days. Client’s worker was supposed to work on the 31st of December 2019. Firstly, working on the 31st is an achievement. Since we can’t affect it, “bug report” was filled on our end....

December 7, 2018 · 1 min · anvyst

CakePHP CsvMigrations: prototype in 3 2 .. Done!

Every programmer is tired of coding yet another login form. Yet another CRUD view module. So today I’ll show you an example where our laziness can get you building prototype systems without a single line of extra code. One of the tasks, that we had to face when developing Qobrix CRM, was fast prototyping of the system. The result of ultimate laziness and DRY concept resulted in cakephp-csv-migrations plugin that we try to use pretty much everywhere, while delivering the system....

February 2, 2018 · 4 min · anvyst

CakePHP: Interview with Larry E. Masters

Interesting interview with one of the core members of CakePHP community - Larry E. Masters. Throughout the interview Larry covers CakePHP Framework history, as well as covering major milestones of CakePHP 3.x version. If you’re still into 2.x then it’s time to upgrade, as it brings some nice perks. More flexible code, and massive performance boost.

May 29, 2017 · 1 min · anvyst

PHP: Testing protected methods in CakePHP3

One of the things I recently had to deal with - PHP unit testing protected methods of the class in CakePHP 3. Few seconds of checking StackOverflow brought a nice and elegant way of checking protected methods using ReflectionClasses. Sebastian Bergmann has a complete guide how to check non-public functionality of the classes in his archieves. Here’s a short sample of the code using CakePHP3: <?php use Search\Model\Table\SaveSearchTable; use Cake\TestSuite\TestCase; class SaveSearchTableTest extends TestCase { public function setUp() { $this->SavedSearches = \Cake\ORM\TableRegistry::get('SavedSearches'); } public function testProtectedMethod() { $methodName = 'protectedMethod'; $reflectionClass = new \ReflectionClass('\Search\Model\Table\SaveSearchesTable'); $method = $reflectionClass->getMethod($methodName); $methodResult = $method->invokeArgs( $this->SavedSearches, ['arg1', ['arg2']]); $this->assertNotEmpty($methodResult); } }

February 7, 2017 · 1 min · anvyst

CakeDC upgrade adds Google Authenticator

Few days of work, and almost a month of waiting. It was totally worth it. Yesterday noon, CakeDC community upgraded one of its major plugins with our Qobo patch. It allows users to enable Google Authenticator. There’s no need anymore to use ‘dev-develop’ branches in composer.

December 20, 2016 · 1 min · anvyst

Google Authenticator in CakePHP3.x

Google Authenticator gets a new wave of interest from the web community, trying to put an extra layer on top of user authentication process. There’s a plethora of plugins and components that let you authenticate with Google, but most of them aim to OAuth and Google+ integration. Two-step auth gets aside. I took few hours on research for the simple 2FA library available on the net and found TwoFactorAuth that already support Google URI QR-codes, that can be easily embedded into any framework/application running on PHP....

November 25, 2016 · 2 min · anvyst

Qobo: first month benchmark

It’s been already one month since I moved to Qobo Ltd, as a backend developer, so it’s about time to do some benchmarks on the work done. Open-Source The level of open source involvement of Qobo is enormous. All the projects I’ve been involved in before were always about open-source: it was either based on open-source, or using open-source solutions into some extend. Every time it ends up locking down the solutions for indoor use....

November 15, 2016 · 2 min · anvyst

Chronos: CakePHP replacement for carbon

Chronos is a drop-in library replacement for nesbot/carbon. It provides immutable date/datetime objects. Immutable objects help us to ensure, that DateTime objects aren’t accidentally modified. <?php<br>require 'vendor/autoload.php';<br>use Cake\Chronos\Chronos;<br>printf("Now: %s", Chronos::now());<br>?>

August 23, 2016 · 1 min · anvyst

CakePHP 3 adopts PSR-2

Recently read this article from James Watts: By adopting PSR-2 we can remove or reduce the code we maintain related to enforcing coding standards. As there are common tools, used by the rest of the community, to validate and revise CS issues, without requiring exceptions. james watts Looks like it’s the time to re-write our internal modules with PSR-2 standards in mind. If we want to share them with open-source community, of course

December 23, 2014 · 1 min · anvyst