PHP ClassesNotable PHP package: Jaxon (29.7.2016, 21:31 UTC)
By Manuel Lemos
Many Web applications have browser side (JavaScript) code making AJAX calls to server side code in PHP that is mapped to classes of objects.

Usually the server side code needs to register classes or functions that will handle the AJAX calls.

However, when you have many classes to handle your Web application AJAX calls, registering classes one by one can be a tedious time consuming task.

The package provides a more efficient method to register many classes at once. You just specify a directory and the package will lookup and load the classes on demand when the AJAX calls are received.

This way you also do not have to waste time instantiating objects of the handler classes until they are necessary.

Read this article to learn more details about how this notable PHP package works.
Link
Christian WeiskePHP does not see Authorization header (29.7.2016, 20:17 UTC)

While implementing a micropub token endpoint I noticed that I was unable to access the value of an HTTP Authorization header - $_SERVER did not include it.

$ curl -H 'Authorization: Bearer wolf' 127.0.0.1/dumpserver.php |grep -i auth
$

It turns out that you manually have to pass them, e.g. by adding the following line to your .htacess file:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
$ curl -H 'Authorization: Bearer wolf' 127.0.0.1/dumpserver.php |grep -i auth
  'HTTP_AUTHORIZATION' => string 'Bearer wolf'(length=11)
$
Link
Voices of the ElePHPantInterview with Vesna Kovach (29.7.2016, 13:55 UTC) Link
PHP ClassesPHP Articles Report July 2016 Edition (29.7.2016, 06:03 UTC)
By Manuel Lemos
This is the July edition of the podcast hangout recorded by Manuel Lemos and Arturs Sosins to comment on the latest outstanding PHP Articles published recently.

They commented on articles about using DevSense PHP Tools extension to develop and debug PHP applications with Visual Studio, automating actions on Mac OS X using PHP scripts, using reactive programming to develop more efficient PHP applications, debugging remote projects with PHPEd, and a new series of short videos to tell why developers should create their own software products and sell to many customers, and what are the main mistakes to avoid to become successful doing that.

Listen to the podcast, or watch the hangout video to learn more about these PHP articles.
Link
Nomad PHP“New” is Not Your Enemy! (29.7.2016, 04:00 UTC)

October 2016 - EU
Presented By

Stephan Hochdörfer
October 13, 2016
20:00 CEST

The post “New” is Not Your Enemy! appeared first on Nomad PHP.

Link
Rob AllenChecklist for releasing Slim (28.7.2016, 10:58 UTC)

Release process for Slim so that I don't forget any steps; based on a check list created by Asgrim. I should probably automate some of this!

Preparation:

  • Ensure all merged PRs have been associated to the tag we're about to release.
    Find them via this search: [is:pr is:closed no:milestone is:merged].
  • Close the milestone on GitHub.
  • Create a new milestone for the next patch release.
  • Ensure that you have the latest master & that your index is clean.
  • Find the ID of the current milestone. This is the numeric id found in the URL of the milestone detail page (e.g. 34).
  • Generate the changeling using changelog_generator & copy to clipboard:
    changelog_generator.php -t {your-github-api-token} -u slimphp -r Slim -m {ID} | pbcopy

Tag and release:

  • Edit App.php and update the VERSION constant to the correct version number. Commit the change.
  • Tag the commit: git tag -s {x.y.z} & paste the change log generated above into the tag message.
  • Update App.php again and set the VERSION constant to {x.y+1.0}-dev & commit.
  • Push the commits and the new tag: git push --follow-tags
  • Go to the releases page and click "Draft a new release":
    • Enter the tag name and ensure that you see a green tick and "Existing tag" appear.
    • Set the release title to the same as the tag name.
    • Paste the change log generated above into the release notes box (it is already formatted with Markdown).
    • Click "Publish release".
  • Write announcement blog post for website & publish.
Link
PHP ClassesReview: Mastering Laravel (28.7.2016, 05:20 UTC)
Mastering Laravel
Title
Reviewer
Lopo Lencastre de Almeida
Category
PHP books
Publisher
Packt
Author
Christopher John Pecoraro
Summary
As I mentioned before, Laravel is one of the most exciting of the newer PHP frameworks and it will gain more market share in the near future. It's already the most starred PHP framework on Github and that says a lot about its popularity, so you should really consider to have it as one of your expertise areas.

With this new version you will also have a stable Long Term Support Laravel and you can be more confident on working with it.

This book is a natural follow up of the previous "Laravel 5 Essentials" book, also from PacktPub. If you are not anymore a newbie to Laravel this is a very good book to follow your path to mastering Laravel as a Pro.
Link
SitePoint PHPHassle-Free Filesystem Operations during Testing? Yes Please! (27.7.2016, 16:00 UTC)

When working with the filesystem in our tests suites, a big concern is cleaning up the temporary files after each test runs. However, if for any reason the test's execution is interrupted before the cleanup phase, further tests might fail, as the environment has not been cleaned up.

In this post, we will use a library named vfsStream to create filesystem mocks. It's little more than a wrapper around a virtual filesystem, which also works very nicely with PHPUnit.

Note This post requires a basic understanding of unit testing and PHPUnit.

To have something to test, we'll write a simple class for creating files:

<?php
// FileCreator.php
class FileCreator {

    public static function create($path, $name, $content)
    {
        $file_name = rtrim($path, '/') . '/' . $name;

        if (file_put_contents($filename, $content)){
            return true;
        }
        return false;
    }
}

Inside the class, we have a create() method, which accepts the filename, content, and a path to which to save it.

To test the class, we first take the traditional approach, and create a test class without using a virtual filesystem. Then, we'll bring vfsStream into the game to see how it can simplify the testing process for us.

Traditional Approach

<?php

class FileCreatorTest {

    protected $path;

    public function setUp()
    {
        $this->path = sys_get_temp_dir();
    }

    public function tearDown()
    {
        if (file_exists($this->path . '/test.txt')) {
            unlink($this->path . '/test.txt');
        }
    }

    public function testCreate()
    {
        $this->assertTrue(FileCreator::create($this->path, 'test.txt', 'Lorem ipsum dolor sit amet'));
        $this->assertFileExists($this->path . '/test.txt');

    }

In the above, we define the temporary directory (in setUp()) which we'll use for our temporary files by using PHP's sys_get_temp_dir(). The function returns the system's directory path for temporary files.

Continue reading %Hassle-Free Filesystem Operations during Testing? Yes Please!%

Link
PHP ClassesNotable PHP package: CMS Airship (27.7.2016, 06:37 UTC)
By Manuel Lemos
PHP is often blamed for being an insecure language. This is not a fair claim because, as a language, PHP is not more insecure than most other Web programming languages.

The bad reputation could be attributed to some applications like WordPress and others that can be easily extended with plugins developed by programmers that may not be so security aware as they should.

The CMS Airship package is a content management system package that was developed and managed to be secure by design.

It is mainly a blog engine with support for multi-site environments.

It can be extended with add-ons that can be reviewed and controlled by the community, thus helping to quickly fix any security matters that the community finds.

Read this article to learn more details about how this notable PHP package works.
Link
Evert PotREST is in the eye of the beholder (26.7.2016, 17:47 UTC)

The first time I came across the term REST must have been around 2005 or 2006 via Flickr, which was back then in many ways a pioneer in terms of how web applications should be built and designed.

REST, at the time, was a breath of fresh air and it seemed very sane in a world where SOAP and XML-RPC were dominant. I can look at a webservice straight from my browser? Wow. Returning simple XML documents instead of using XML as the transport made a lot of sense.

I’m not really sure if Flickr was the first to use the term REST for that type of service, but in my memory it played a fairly big part in popularizing it.

I used the wayback machine to find these early examples, but then quickly realized that the Flickr API has actually not changed!

But it’s not REST

It took me some time, but I slowly started realizing that this was actually not a REST service. Not before I deployed a similar API and stamped it “REST” though.

As it turns out, REST is more than “simple documents”. We learn we also need to use correct HTTP Verbs such as GET, PUT and DELETE where appropriate.

Over time the definition for me and many people around me evolves, which eventually brought me to a point where I found out what the original definition was all along.

REST stands for “Representational State Transfer” and was invented by Roy Fielding, one of the authors of HTTP/1.1 and described in his dissertation.

REST has a specific meaning and a ‘best practice way’ to implement it when using HTTP, and Flickr and pretty much anyone else joining the REST hype is getting it wrong, much to Fieldings annoyance (2008).

And he’s not alone. What follows is a storm of articles, conference talks, tweets and even some books describing what REST is and describing in what way many people got it wrong.

So what is REST?

Well, over time we’ve gotten better at describing what REST is. We now have the term HATEOAS, which rolls off the tongue amazingly. A service cannot call itself REST unless it’s also HATEOAS.

We also now have the Richardson Maturity Model, which is a bit like the seven stages of grief, but for REST. Basically, you cannot call your service REST unless you’re on Level 3 of the Maturity Model.

I’d highly recommend reading the fowler article, because it’s one of the best overviews. The maturity model maps out my personal learning curve as well.

But here’s the issue

I believe that “REST” is widely believed to be the “right” way to implement web services. The term is also almost universally used to describe services that actually are not hypermedia-driven a.k.a. not comformant with Level 3 of the Maturity Model.

Almost everyone gets it wrong.

But the thing that they got wrong is not necessarily the API they’ve built. It might be good (enough) and appropriate for what they are trying to accomplish. The thing they get wrong is that according to purists, they should not be calling their service REST, because it aint.

I think doing HATEAOS correctly is overkill for most people. Modelling it correctly is actually quite hard. It’s also prone to a lot of round trips.

A comment from Fielding:

REST is software design on the scale of decades: every detail is intended to promote software longevity and independent evolution. Many of the constraints are directly opposed to short-term efficiency. Unfortunately, people are fairly good at short-term design, and usually awful at long-term design. Most don’t think they need to design past the current release. There are more than a few software methodologies that portray any long-term thinking as wrong-headed, ivory tower design (which it can be if it isn’t motivated by real requirements).

The reality is that a lot of us actually do see the value of achieving short-term goals, preferring ease-of-use over correctness. We’re not building an API for the library of congress. Having lots of people use an API is probably more important than that API being relevant for multiple decades.

Truncated by Planet PHP, read more at the original (another 2755 bytes)

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP