PHP Directory

Blogs

  • Notable PHP package: Jaxon

    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.
  • PHP does not see Authorization header

    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)
    $
  • Interview with Vesna Kovach

    The post Interview with Vesna Kovach appeared first on Voices of the ElePHPant.

  • PHP Articles Report July 2016 Edition

    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.
  • “New” is Not Your Enemy!

    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.

  • Checklist for releasing Slim

    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.
  • Review: Mastering Laravel

    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.
  • Hassle-Free Filesystem Operations during Testing? Yes Please!

    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!%

  • Notable PHP package: CMS Airship

    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.
  • REST is in the eye of the beholder

:: Our Favorites

Featured Sites Using PHP

>Atlanta Real Estate