Mitchell McKenna - tagged with php http://mitchmckenna.com/feed en-us http://blogs.law.harvard.edu/tech/rss LifePress mitchellmckenna@gmail.com PHP isn't dead feat. the Laravel Origins cast http://mitchmckenna.com/post/19180/php-isnt-dead-feat-the-laravel-origins-cast

During the production of Laravel Origins, we asked the cast about their thoughts on the current state of PHP and how they feel when other programmers claim that PHP is dead.

]]>
Tue, 19 Apr 2022 13:05:00 -0400 http://mitchmckenna.com/post/19180/php-isnt-dead-feat-the-laravel-origins-cast/php-isnt-dead-feat-the-laravel-origins-cast
Code Snippets with PhpStorm Live Templates – Christoph Rumpel http://mitchmckenna.com/post/19005/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4

Christoph Rumpel demos PhpStorm code snippets a.k.a. live templates.

]]>
Thu, 10 Sep 2020 05:08:00 -0400 http://mitchmckenna.com/post/19005/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4
Next time you're trying to decide between == and === I hope you think of how scary this is php http://mitchmckenna.com/post/18743/mitchellmckenna-next-time-youre-trying-to-decide-between-and-i-hope-you-think-of-how-scary-this-is-php-httpstcoiyadrtwqss

Next time you're trying to decide between == and === I hope you think of how scary this is #php https://t.co/IYADrTWqsS

]]>
Fri, 01 Mar 2019 14:42:00 -0500 http://mitchmckenna.com/post/18743/mitchellmckenna-next-time-youre-trying-to-decide-between-and-i-hope-you-think-of-how-scary-this-is-php-httpstcoiyadrtwqss/mitchellmckenna-next-time-youre-trying-to-decide-between-and-i-hope-you-think-of-how-scary-this-is-php-httpstcoiyadrtwqss
/u/mitchmckenna on What's your HTML DOM parser of choice, for scraping web pages? I used Simple HTML DOM a few years ago, but now I'm starting a new project so need to know what people recommend nowadays. http://mitchmckenna.com/post/18518/umitchmckenna-on-whats-your-html-dom-parser-of-choice-for-scraping-web-pages-i-used-simple-html-dom-a-few-years-ago-but-now-im-starting-a-new-project-so-need-to-know-what-people-recommend-nowadays

Goutte has a great API

]]>
Sun, 26 Aug 2018 18:57:00 -0400 http://mitchmckenna.com/post/18518/umitchmckenna-on-whats-your-html-dom-parser-of-choice-for-scraping-web-pages-i-used-simple-html-dom-a-few-years-ago-but-now-im-starting-a-new-project-so-need-to-know-what-people-recommend-nowadays/umitchmckenna-on-whats-your-html-dom-parser-of-choice-for-scraping-web-pages-i-used-simple-html-dom-a-few-years-ago-but-now-im-starting-a-new-project-so-need-to-know-what-people-recommend-nowadays
/u/mitchmckenna on Examples of powerful php applications not website http://mitchmckenna.com/post/18441/umitchmckenna-on-examples-of-powerful-php-applications-not-website

Slack, Vimeo, Nordstrom, Huffington Post, Engadget, TechCrunch, SalesForce, eBay, Etsy, Eventbrite, Adobe, 23andMe, Twilio, Intuit, Udemy, Rakuten These companies all have apps for iOS/Android/Apple TV/etc apps that have backends powered by PHP.

]]>
Sun, 15 Jul 2018 12:07:00 -0400 http://mitchmckenna.com/post/18441/umitchmckenna-on-examples-of-powerful-php-applications-not-website/umitchmckenna-on-examples-of-powerful-php-applications-not-website
Git Blame from within PHPStorm! How did I not know about this?! PHP http://mitchmckenna.com/post/18004/mitchellmckenna-git-blame-from-within-phpstorm-how-did-i-not-know-about-this-php-httpstcojnvgseeont

Git Blame from within PHPStorm! How did I not know about this?! #PHP https://t.co/jNVgseEOnt

]]>
Thu, 30 Nov 2017 21:03:00 -0500 http://mitchmckenna.com/post/18004/mitchellmckenna-git-blame-from-within-phpstorm-how-did-i-not-know-about-this-php-httpstcojnvgseeont/mitchellmckenna-git-blame-from-within-phpstorm-how-did-i-not-know-about-this-php-httpstcojnvgseeont
NewJob I joined @zulilytech mobile API team at their HQ in Seattle! Modernizing PHP code, migrating to AWS, and helping scale http://mitchmckenna.com/post/17963/mitchellmckenna-newjob-i-joined-zulilytech-mobile-api-team-at-their-hq-in-seattle-modernizing-php-code-migrating-to-aws-and-helping-scale-apis

#NewJob I joined @zulilytech mobile API team at their HQ in Seattle! Modernizing #PHP code, migrating to AWS, and helping scale APIs 👨🏻‍💻

]]>
Tue, 31 Oct 2017 11:55:00 -0400 http://mitchmckenna.com/post/17963/mitchellmckenna-newjob-i-joined-zulilytech-mobile-api-team-at-their-hq-in-seattle-modernizing-php-code-migrating-to-aws-and-helping-scale-apis/mitchellmckenna-newjob-i-joined-zulilytech-mobile-api-team-at-their-hq-in-seattle-modernizing-php-code-migrating-to-aws-and-helping-scale-apis
How to use Laravel's new API Resources to follow JSONAPI http://mitchmckenna.com/post/17865/mitchellmckenna-how-to-use-laravels-new-api-resources-to-follow-jsonapi-spec-httpstcoxpmmfhsuzy-tutorial-php

How to use #Laravel's new API Resources to follow #JSONAPI spec https://t.co/xPmmfhSuZy #tutorial #php

]]>
Thu, 21 Sep 2017 17:13:00 -0400 http://mitchmckenna.com/post/17865/mitchellmckenna-how-to-use-laravels-new-api-resources-to-follow-jsonapi-spec-httpstcoxpmmfhsuzy-tutorial-php/mitchellmckenna-how-to-use-laravels-new-api-resources-to-follow-jsonapi-spec-httpstcoxpmmfhsuzy-tutorial-php
Building a jsonapi in Laravel? I created an example API with features & packages I've found really http://mitchmckenna.com/post/17827/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php

Building a #jsonapi in #Laravel? I created an example API with features & packages I've found really useful! https://t.co/22ysAP7tvU #php

]]>
Tue, 05 Sep 2017 13:02:00 -0400 http://mitchmckenna.com/post/17827/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php
Laravel Horizon revealed: a dashboard for queue monitoring and job management http://mitchmckenna.com/post/17725/mitchellmckenna-laravel-horizon-revealed-a-dashboard-for-queue-monitoring-and-job-management-httpstcowflcnicaph-opensource-php

Laravel Horizon revealed: a dashboard for queue monitoring and job management https://t.co/WfLCnIcaph #opensource #php

]]>
Tue, 25 Jul 2017 17:44:00 -0400 http://mitchmckenna.com/post/17725/mitchellmckenna-laravel-horizon-revealed-a-dashboard-for-queue-monitoring-and-job-management-httpstcowflcnicaph-opensource-php/mitchellmckenna-laravel-horizon-revealed-a-dashboard-for-queue-monitoring-and-job-management-httpstcowflcnicaph-opensource-php
shrikeh/teapot - HTTP Status Codes (PHP Package) http://mitchmckenna.com/post/17065/shrikehteapot-http-status-codes-php-package

If you are using Laravel or Symfony for comparing http status codes eg $status_code = Response::HTTP_NOT_FOUND you might find this library helpful $status_code = Http::NOT_FOUND - it's a little shorter, and the whole RFC description of the status code is in the docblock so you don't have to google what it means.

]]>
Wed, 17 Aug 2016 16:31:00 -0400 http://mitchmckenna.com/post/17065/shrikehteapot-http-status-codes-php-package/shrikehteapot-http-status-codes-php-package
Grafika - Image Processing Library PHP http://mitchmckenna.com/post/16943/grafika-image-processing-library-php

Grafika is an image processing library for PHP. It can be used to resize, crop, compare, and add watermark on images. It can also create texts, geometric shapes, and apply filters. Its built on top of Imagick and GD.

]]>
Mon, 25 Jul 2016 12:38:00 -0400 http://mitchmckenna.com/post/16943/grafika-image-processing-library-php/grafika-image-processing-library-php
A little article I wrote about PSR-7, function naming, and convention http://mitchmckenna.com/post/16838/mitchellmckenna-rt-baileylo-a-little-article-i-wrote-about-psr-7-function-naming-and-convention-httpstcodf2sshj1ek-php

RT @baileylo: A little article I wrote about PSR-7, function naming, and convention https://t.co/DF2ssHj1EK #php

]]>
Thu, 16 Jun 2016 17:32:00 -0400 http://mitchmckenna.com/post/16838/mitchellmckenna-rt-baileylo-a-little-article-i-wrote-about-psr-7-function-naming-and-convention-httpstcodf2sshj1ek-php/mitchellmckenna-rt-baileylo-a-little-article-i-wrote-about-psr-7-function-naming-and-convention-httpstcodf2sshj1ek-php
php has gotten a lot of awesome new features, but is it scaring off beginners? http://mitchmckenna.com/post/16371/mitchellmckenna-php-has-gotten-a-lot-of-awesome-new-features-but-is-it-scaring-off-beginners-httpstcojzacaczgjd-by-baileylo

#php has gotten a lot of awesome new features, but is it scaring off beginners? https://t.co/jzAcAcZgJd /by @baileylo

]]>
Tue, 12 Apr 2016 15:51:00 -0400 http://mitchmckenna.com/post/16371/mitchellmckenna-php-has-gotten-a-lot-of-awesome-new-features-but-is-it-scaring-off-beginners-httpstcojzacaczgjd-by-baileylo/mitchellmckenna-php-has-gotten-a-lot-of-awesome-new-features-but-is-it-scaring-off-beginners-httpstcojzacaczgjd-by-baileylo
Laravel Queued Jobs + Doctrine - Fix Objects Not Updating Between Jobs Run http://mitchmckenna.com/post/15632/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run

The issue is that doctrine is keeping the objects in local memory because the daemon is basically a php long-running process. In order to allow the objects used by the job to get updated, you need to $em->detach() the objects. But you'd also have to have cacade={"detach"} on all relationships that object has as well. So the best thing is to just call $em->clear() at the end of your job. This will detach all objects from doctrine and it will get a fresh copy of all the objects from the database for the next job run.

]]>
Wed, 10 Feb 2016 07:34:54 -0500 http://mitchmckenna.com/post/15632/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run
Laravel Queued Jobs + Doctrine - Fix Mysql Has Gone Away Errors http://mitchmckenna.com/post/15630/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors

With long running processes you can get a 2006 MySQL server has gone away error. This adds a class that calls Doctrine's DBAL Connection's $conn->ping() to see if it's gone away, if so close the connection and let DBAL automatically open a new connection on the next query attempt. This is talked about in the Doctrine's Github repo here. Here's some pseudo code on how to do it:

<?php

namespace Acme\Doctrine\ORM;

use Doctrine\ORM\EntityManager;

class ConnectionSaver
{
    /**
     * Ping the DB server, if connection is lost close it and DBAL will
     * automatically reconnect on the next DB call.
     */
    public function checkDatabaseConnection()
    {
        /** @var \Doctrine\DBAL\Connection */
        $conn = app(EntityManager::class)->getConnection();

        try {
            $ping = $conn->ping();
        } catch (\ErrorException $e) {
            $conn->close();
        }
    }
}

Then inside the command handler you just inject the class and call checkDatabaseConnection() function.

<?php

namespace App\Listeners\Commands;

use Acme\Doctrine\ORM\ConnectionSaver;

class FooHandler
{
    public function __construct(ConnectionSaver $connectionSaver) {
        $connectionSaver->checkDatabaseConnection();
    }
]]>
Wed, 20 Jan 2016 03:34:54 -0500 http://mitchmckenna.com/post/15630/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors
Marco Pivetta (Ocramius) - Doctrine ORM Good Practices and Tricks http://mitchmckenna.com/post/15802/phpday-2015-marco-pivetta-doctrine-orm-good-practices-and-tricks

Interesting presentation from one of the Doctrine core team members.

In this Talk, we are going to dive into Doctrine 2 ORM’s feature set. We’re going to see the advantages and disadvantages of each functionality, with a particular focus on use-cases that each functionality attempts to solve, which features should be used with care (or avoided completely) and which ones should be used even more.

]]>
Tue, 29 Sep 2015 17:39:00 -0400 http://mitchmckenna.com/post/15802/phpday-2015-marco-pivetta-doctrine-orm-good-practices-and-tricks/phpday-2015-marco-pivetta-doctrine-orm-good-practices-and-tricks
JMS Serializer - Convert objects to and from JSON, XML, YAML, etc http://mitchmckenna.com/post/15793/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc

Say you're building an API, you need to convert the objects you send in the response to JSON representation (removing certain properties like passwords, and modifying others like dates) you can use JSMSerializer to define how that happens automatically. But where JSMSerializer really shines is how it can deserialize data into PHP objects. Maybe you you are consuming a JSON feed, you can use this to convert each object in the JSON feed to an object. You do this by registering "handlers" for each object type. You can do all this configuration via annotations, XML or YAML (which you'll be familiar with if you've used Doctrine). It also includes an event system, which you can use to hook into modifying the data before serialization or right afterward it happens.

]]>
Sun, 27 Sep 2015 15:53:00 -0400 http://mitchmckenna.com/post/15793/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc/jms-serializer-convert-objects-to-and-from-json-xml-yaml-etc
Laravel Doctrine - A drop-in Doctrine2 implementation for Laravel 5 http://mitchmckenna.com/post/15757/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5

Several php packages to easily integrate Doctrine 2 into your next Laravel/Lumen project. The 'orm' package includes a ServiceProvider to add Doctrine to your project and configure it. The 'extensions' package includes several extensions including timestampable, softdeletable, etc. The 'migrations' package add ability to use Doctrine's migration package instead of laravel's migrations so that you can easily take advantage of auto migration generation based on entities. The 'ACL' package includes traits to add roles and permissions to user objects to easily integrate with Laravel's new ACL.

]]>
Mon, 14 Sep 2015 14:22:00 -0400 http://mitchmckenna.com/post/15757/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5
Adding Roles and Permissions to Laravel's ACL [Laracasts] http://mitchmckenna.com/post/15754/adding-roles-and-permissions-to-laravels-acl-laracasts

This video tutorial goes over [one way] you can add the ability to give user's roles and specify which permissions those roles have. You would have to build upon this further to include additional features such as role inheritance or user-specific permissions (overrides).

]]>
Sun, 13 Sep 2015 19:26:00 -0400 http://mitchmckenna.com/post/15754/adding-roles-and-permissions-to-laravels-acl-laracasts/adding-roles-and-permissions-to-laravels-acl-laracasts