Paul Jones: Modernizing Serialized PHP Objects with class_alias()

Paul Jones has posted an article to his site with another helpful hint to modernize your legacy PHP application. In the post he looks at updating serialized object handling with the help of the class_alias function.

Several weeks ago, a correspondent presented a legacy situation that I’ve never had to deal with. He was working his way through Modernizing Legacy Applications in PHP, and realized the codebase was storing serialized PHP objects in a database. He couldn’t refactor the class names without seriously breaking the application. […] Before I was able to reply, my correspondent ended up changing the serialization strategy to use JSON, which was a rather large change. It ended up well, but it turns out there is a less intrusive solution: class_alias().

He talks about how this function could be useful to prevent the need for updating the class name in every serialized instance by setting up an alias to the new name. You can even use namespacing in the alias that will let the autoloader work with the PSR-0/PSR-4 handling to correctly load the class. With this in place, you can then refactor to the new version of the class without worry of breakage.

Link: http://paul-m-jones.com/archives/6158
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

Frank de Jonge: Packages vs. Components: The Dependency Problem.

In a new post to his site Frank de Jonge makes a distinction between packages versus components, pointing out that components are always packages but packages are not always components, and what it really boils down to is a problem of dependency.

The PHP landscape has fully transitioned into its Package Age™ […] However, due to PHP’s nature, there are some problems. While packages are great for re-use outside of frameworks, dependencies are still an issue. Namespaces resolve conflicts between classnames, but they do not offer a solution to package versioning. Especially in a framework-context, this can become very problematic. A real-world-example for this is Guzzle.

In his Guzzle example he describes the main problem – when packages restructure or make changes incompatible with prior versions and dependencies conflict and both must be installed. He also points out that, while this is bad for just packages, it can be made even worse working with components (his name for framework-based packages). Problems he mentions are the previously mentioned dependency conflicts but also some unexpected quirks with how Composer chooses to install packages. He gives an example of this second one with the installation of the Symfony EventDispatcher component and how, upon closer inspection, Composer seems to be installing two versions of the library at once.

Link: http://blog.frankdejonge.nl/packages-vs-components/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

Symfony Finland: Serving PHP on HTTP/2 with H2O and HHVM (Symfony, WordPress, Drupal…)

On the Symfony Finland blog there’s a new post showing you how to serve PHP over HTTP/2 with HHVM and H2O. H2O describes itself as a „new generation HTTP server providing quicker response to users when compared to older generation of web servers“.

This article is not about improvements made in HTTP/2 – as there are plenty of locations for you to read up on the internals. It’s a hands on article to get started using HTTP/2 today with popular tools such as Symfony, WordPress and Drupal with the HHVM PHP runtime from Facebook. You can just as well use PHP-FPM.

They start with a bit of a look at the current state of PHP and HTTP/2 on the various major web server types. H2O, while younger, natively supports HTTP/2, he does offer the caveat that „waiting won’t kill you“. Despite this, they go on to show you how to set up the PHP+H2O+HHVM combination complete with configuration examples and what to look for in the logs to ensure HTTP/2 functionality.

Link: https://www.symfony.fi/entry/serving-php-on-http-2-with-h2o-and-hhvm-symfony-wordpress-drupal
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , , | Hinterlasse einen Kommentar

Sammy Powers: Contributing to the PHP Manual

If you’ve wanted to contribute something back to PHP but aren’t familiar with C (or don’t feel comfortable enough with it) Sammy Powers offers another solution. In his latest post he shows you how to contribute to the PHP documentation and update the manual for new features, missing information or fixes to current code examples.

If you’ve been wanting to contribute to PHP internals, starting with the documentation can be a great entry point; especially because it doesn’t require dusting off those old C books from college. But knowing where to start can be tricky since information on how to contribute to the docs is scattered across the internet. This article is a step-by-step guide of how to contribute documentation to the PHP manual.

He starts with the „quick and dirty“ way of editing the manual through the edit.php.net site, but points out that it’s really only useful for smaller changes, not large documentation updates. The rest of the post shows you how to set up the documentation locally and generate the results to validate your changes. He talks some about the DocBook format they’re written in, the build process with the PhD (PHP docs generator) and running the php.net test suite against the changes. This ensures that nothing else has broken on the site in the process.

He shows you where to make your changes, how to generate it from either a skeleton or using the docgen script and submitting the changes back to the repository. There’s also a few other random changes to make before committing the files back via SVN and pushing them back upstream. He ends the post talking about the GoPHP7-ext project and how to find extensions that are missing documentation or where it’s incomplete (easy thanks to an included „check-missing-docs“ file included in the repository).

Link: https://www.sammyk.me/how-to-contribute-to-php-documentation
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , | Hinterlasse einen Kommentar

Hafiz Waheeduddin Ahmad: API Testing: Installing and Using Codeception

Hafiz Waheeduddin Ahmad has a new post to his site, part three of a series he’s posted on API testing, looking at the use of Codeception for testing API output and functionality.

In this post, we will have a look on how we can use Codeception for API testing.

He starts by helping you get Codeception installed through Composer through a „require“ command line call. He then walks you through the setup of the project and how to use the „codecept“ command line tool. He covers the generated directory structure the bootstrapping created and how to set up a sample configuration for your API. He then gets into writing an example test, showing how to check things like authentication, HTTP header information, response codes and response contents. Finally he shows how to run the tests in both a normal and more verbose way.

Link: http://haafiz.me/development/api-testing-installing-and-using-codeception
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

Zend Developer Zone: #20yearsofphp – A Timeline of Tweets

In remembrance of the 20th anniversary of PHP, the Zend Developer Zone has created a new post sharing tweets from the PHP Community Twitter account covering the history of PHP.

My friend – and PHP Community Old Guard – Ben (@ramsey) Ramsey did something awesome for PHP’s 20th, he tweeted out the PHP timeline. I’ve gathered them all here to celebrate both PHP and the work he put into this project.

The post shares a long list of the tweets from the account mentioning the happenings of the last twenty years. It starts with the first release of the language back in 1995 (by Rasmus Lerdorf) and goes all the way up through the present day. It’s been quite a ride over the last 20 years. If you’re new to the PHP community or just want to relive some of the memories of the past, check out the full post!

Link: http://devzone.zend.com/6178/20yearsofphp-a-timeline-of-tweets/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

NetTuts.com: Using the Digital Ocean API to Manage Cloud Instances

In a new tutorial on the NetTuts.com site they show you how to use a Digital Ocean PHP SDK to manage your cloud instances from a PHP-based application.

The Digital Ocean API allows you to manage Droplets and resources in a simple, programmatic way using HTTP requests. All of the functionality that you are familiar with in the Digital Ocean control panel is also available through the API, allowing you to script the complex actions that your situation requires. For this tutorial, we’ll integrate developer Antoine Corcy‚s Digital Ocean V2 PHP API Library into a Yii-based console application.

They walk you through the full process of the setup – getting your access keys, getting the PHP SDK and setting up a component as an interface for the rest of the Yii2 application to use. From there, he shows three examples of the types of commands to can issue:

  • Fetching Droplets
  • Fetching Images
  • Automating Snapshots

Each example comes with the code to implement it and screenshots of both how the same functionality looks in the Digital Ocean control panel and the output of their script.

Link: http://code.tutsplus.com/tutorials/using-the-digital-ocean-api-to-manage-cloud-instances–cms-22864
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

ServerGrove Blog: Linters for PHP projects

In a new post to the ServerGrove blog they look at linting tools for various circumstances including standard PHP, Twig templates and Composer configuration.

Today’s projects are built up from dozens of different components, configuration files, third-party libraries, tests, build scripts, etc. And even if you have the greatest test suite, bad things can happen sometimes. It’s important to catch bugs as early as possible, and syntax validators can be a great (and easy) addition to your continuous integration system. You would be surprised at how many problems are caused by syntax errors. At ServerGrove, we see these kind of problems with our clients almost every day.

Their list shows you how to lint (syntax check) several different types of content:

  • standard PHP code
  • Twig templates
  • Composer configuration
  • XML files
  • Bash scripts
  • JSON files
  • YAML files

Some of them use tools that already come built-in (like PHP’s „-l“ or Twig’s „twig:lint“) but others require the use of external software such as xmllint or melody. Command examples are also included for each.

Link: http://blog.servergrove.com/2015/06/02/linters-php-projects/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , | Hinterlasse einen Kommentar

PHP Roundtable: 021: From Idea To Production: Part 1

The PHP Roundtable podcast, hosted by Sammy Powers, has a new show posted (#21) staring off a series about moving from just an idea to a production application. His guests for this episode are Steven Maguire, Jocelyn Lopez and Glen Hinkle.

We discuss an idea for a web app and identify ways to turn it into a real-life product on the web.

We start with describing the domain and the problems the app should solve. Then we identify the personas that will interact with the app. We discuss the features features the app should have to fix the problems and we sort all the features by priority. Finally we talk about timeline, deliverables and next steps. The app we discuss will be launched to production by the next airing of this multi-part series of taking an idea to code.

You can watch this latest episode either through the in-page video player or directly over on YouTube

Link: https://www.phproundtable.com/episode/part-1-turning-an-idea-into-code-for-production
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , | Hinterlasse einen Kommentar

Binary Studio Blog: Definitive Guide On Creating Custom Providers For Laravel OAuth2 Authorization

A new guide has been posted showing you how to create custom OAuth2 providers for your Laravel application. In this case they wanted to hook the application in via Socialite to the VK social network but needed a custom connector to make it happen.

First of all let’s say that social authorization is very popular and frankly speaking it’s really handy tool. Surfing internet we can see a lot of sites and services which offer login with Facebook, Twitter, Google and other social networks. […] If you’re building your website in PHP using Laravel, probably you’ve noticed Socialite which provides OAuth / OAuth 2 authentication with Facebook, Twitter, Google, and GitHub. The most famous social network which provides OAuth2 authentication in Russian segment of the internet is vk. But there is a lack of such connector (provider) in Socialite library. Actually it’s not a hard problem, so let’s build new VkProvider on top of Socialite’s components.

He starts with a brief look at the typical OAuth2 authentication flow between the social network and your application. From there it gets more vk.com specific. He shows how to set up the custom application on their side, updating your configuration with the credentials and installing Socialite. He then implements a „VkProvider“ defining the required methods based on the interface. He then registers it as a „SocialiteServiceProvider“ and uses it in a „login“ request route.

Link: http://binary-studio.com/2015/05/25/laravel-oauth2/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , , , , , | Hinterlasse einen Kommentar