<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by jrdn. on Medium]]></title>
        <description><![CDATA[Stories by jrdn. on Medium]]></description>
        <link>https://medium.com/@jrdnrc?source=rss-f4863ec47c9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QBfH934ccdXNQvrl.jpeg</url>
            <title>Stories by jrdn. on Medium</title>
            <link>https://medium.com/@jrdnrc?source=rss-f4863ec47c9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:04:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jrdnrc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Decoding GMail Messages in PHP]]></title>
            <link>https://medium.com/@jrdnrc/decoding-gmail-messages-in-php-408194aeb767?source=rss-f4863ec47c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/408194aeb767</guid>
            <category><![CDATA[google-api]]></category>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[jrdn.]]></dc:creator>
            <pubDate>Wed, 22 Mar 2017 08:55:17 GMT</pubDate>
            <atom:updated>2017-03-22T09:19:35.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*-fg9kzm0Ore3gKWg8lKo9w.jpeg" /></figure><p>When searching through GMail messages, you have two options: connect using the IMAP protocol, or use the Google GMail API.</p><p>Unfortunately, the IMAP protocol is often a non-starter, as the C extension installed may not support IMAP4, which GMail uses. This makes it impossible to query a gmail mail list.</p><p>However, where there is a will, there is a way! Using a PHP extension and package, it is possible to connect to GMail, search through, and read your messages.</p><p>This article is going to assume a working knowledge of the basic PHP Google API, including setting up API credentials and connecting an account via OAuth2.</p><p>Firstly, we need the Mail Parse extension for PHP. You can install this by running pecl install mailparse. Ensure this extension is then enabled in PHP.</p><p>Next up is the mail parser package, which you can install by running composer require &quot;php-mime-mail-parser/php-mime-mail-parser:^2.8.0&quot;.</p><p>After these are installed, and you are authenticated with Google and GMail, searching through and retrieving messages is a simple task.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2bb0e90525aa01718cf9359f1b20d02/href">https://medium.com/media/f2bb0e90525aa01718cf9359f1b20d02/href</a></iframe><p>The $rawDataarray will consist of a list of Base 64 encoded data. This is where the real “gotcha” comes in — this is not the same as PHP’s inbuilt base64_encode($data), rather, it is base 64 URL encoded. If you run base64_decode on the raw data provided, you will end up with unreadable and unparseable garbage.</p><p>To overcome this, you need to replace a couple of characters in the encoded data, mainly — and _ with + and / respectively.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14405da77fa18489bc2281db4871454c/href">https://medium.com/media/14405da77fa18489bc2281db4871454c/href</a></iframe><p>You can now run base64_decode on the string and get a readable, parseable string of data, that php-mime-mail-parser can handle.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08f6677740b9822d87a0dceb230be8a4/href">https://medium.com/media/08f6677740b9822d87a0dceb230be8a4/href</a></iframe><p>More documentation on the mail parser is available on its GitHub repository, located at <a href="https://github.com/php-mime-mail-parser/php-mime-mail-parser#readme">https://github.com/php-mime-mail-parser/php-mime-mail-parser#readme</a>.</p><p>As well as the creator of the mailparse extension and the parser package, I would like to thank the unknown user3788724 who detailed the difference between base 64 encoding, and base 64 URL encoding <a href="http://stackoverflow.com/a/24481560/2107323">here</a>.</p><p>Hopefully this will help someone figure out how to read gmail messages using the PHP API quicker than I did!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=408194aeb767" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Single Action Controllers]]></title>
            <link>https://medium.com/@jrdnrc/single-action-controllers-a7de27c2c78b?source=rss-f4863ec47c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7de27c2c78b</guid>
            <category><![CDATA[ioc]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[jrdn.]]></dc:creator>
            <pubDate>Fri, 10 Mar 2017 10:35:02 GMT</pubDate>
            <atom:updated>2018-10-15T10:29:10.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Controllers have long been a pain point in web facing applications. They can quickly grow to an unmanageable size, perform too much business logic and generally turn into monolith classes. Often I have seen dependency resolution within the controller, turning it into an unwieldable and untestable mess.</p><p>Symfony has a solution to this in service based controllers. Define your controller, and the depenedencies to inject. Ensure it is not ContainerAware, and you can’t resolve random dependencies on the fly. This can help a developer create a more focused, and testable controller.</p><p>Laravel is similar, in that you can define the dependencies in the constructor method, and if they can be resolved, they will be automatically injected. One minor caveat is that laravel supports dependency resolution (Facades, app() calls, etc), but these can be avoided.</p><p>The latest problem I have been trying to solve, is that even with dependencies strictly injected, controllers acting on the same resource can still become large and unweildly. You can split them into different controllers, but how? Which parts do you split, and into where?</p><p>One solution I have found, is to make use of invokable classes, using the magic method __invoke. Having only a constructor and invoke method results a controller that performs a single action only (Unless you add other controller methods, in which case, why are you using __invoke?).</p><p>This can result in easier unit testing, as each controller is a single unit, and you do not have to inject every dependency for every method to test only one method.</p><p>Controller names can also be more indicative of the action they perform, and you spend less time hunting around controller files for the action you are looking for.</p><p>Laravel supports invokable controllers, although I haven’t tried with Symfony. With Laravel, I have found removing the $namespace field within the RouteServiceProvider allows you to use ::class notation when defining your controllers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99e40b1a4eebfbb7d30c60073dcc7842/href">https://medium.com/media/99e40b1a4eebfbb7d30c60073dcc7842/href</a></iframe><p>Isn’t that much nicer than ‘Path\To\Controller@action’ notation?</p><p><em>Edit:</em></p><p>Ulrich Schmidt-Görtz <a href="https://ulrich.schmidt-goertz.de/posts/single-use-controllers-in-symfony/">pointed out to me</a> that Symfony also contains this behaviour, as you can see in the <a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php#L87">ControllerResolver</a> class. Thanks Ulrich!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7de27c2c78b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NHS Hack Day]]></title>
            <link>https://medium.com/@jrdnrc/nhs-hack-day-1ab13131fb52?source=rss-f4863ec47c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ab13131fb52</guid>
            <category><![CDATA[nhs]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[healthcare]]></category>
            <dc:creator><![CDATA[jrdn.]]></dc:creator>
            <pubDate>Wed, 01 Feb 2017 15:36:50 GMT</pubDate>
            <atom:updated>2017-02-01T15:36:50.311Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the weekend just passed, I attended my first hackathon in Cardiff. The NHS hack day sets its goal as “Making NHS IT less bad” (which, if you’ve had any encounters with the NHS, you should know to be unfortunately true).</p><p>The group of attendees included junior doctors, researchers, developers, designers and a myriad of other skills. Many people, including the pitchers, had a vested interest in the success of the NHS — which was great, as their enthusiasm shone through with their pitches which aimed to solve real problems that workers and patients within the NHS were facing.</p><p>One point I hadn’t fully considered before arriving at the venue was just how stringent security is regarding patient data. I knew security would be a big thing, but I didn’t know just what kind of safeguards are in place for securing and anonymising patient data, and the rules in place for sending patient data over “unsecured” (i.e. not internal behind NHS firewalls) networks. This proved to be a problem when my team discussed sharing our apps data with other NHS services over the internet. Long story short: We couldn’t. And that’s when I began to understand why IT can be sometimes so bad within the NHS. Patient data and security is (rightfully) more of a priority than IT, which results in sucky IT sometimes.</p><p>These security requirements meant that everybody had to think a bit harder about their idea and the execution of the development. Many projects chose to simply step around patient data by not using any.</p><p>One of the projects that stood out for me the most, was a service to help foreign nationals use the NHS services. The service provided a Facebook Messenger chat bot, which could communicate in many different languages, and point a patient towards the nearest hospital, or tell them how to register at a GP. I liked this project as I felt it was a very innovative way of using Messenger bots — up until this point, I had only seen them used to advertise products to the user, and it was uplifting to see one built to help a user instead of just sell them stuff.</p><p>This project managed to avoid those security restrictions by not storing any patient data or using internal NHS services, and produced an impressive service that could be incredibly useful to foreign patients, who would otherwise struggle to utilise the NHS services offered within the U.K.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LnsEfAQ6fO2RFo4ErAWjLw.jpeg" /><figcaption>The team and I</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ab13131fb52" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>