Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Andrew Embler:
Automated Dependency Injection Using Containers
Mar 13, 2018 @ 16:58:42

In a previous post to his site Andrew Embler provided a "concrete guide to dependency injection", a method to help make code easier to test and more flexible/maintainable. In this latest post he continues the series and moves to the next topic: dependency injection containers.

I recently posted about dependency injection, a guide that I hope was easy to read and understand. It's a topic that's confusing, due in no small part to its name. As I mention there, the same term defines the simple process of externally providing instance variables to a class as it does to the Container object's magical auto-instantiation of object (which also "injects dependencies.")

I'd like to talk a bit more about that. Now that we understand the term "Dependency Injection" (which is simply providing classes to classes through a constructor or a setter), let's talk about how we might make this a little less onerous.

He starts with an example from the concrete5 project where a class would require three object instances each time it would be created. Fortunately the software includes a make command that does some of this work for you. It makes use of a dependency injection container behind the scenes to get the instances it needs. He then covers cascading dependencies, some special logic for class creation and how to "get fancy with it" by defining custom logic when an instance is created.

tagged: dependency injection container concrete5 instance tutorial

Link: http://andrewembler.com/2018/03/automated-dependency-injection-using-containers

thePHP.cc:
Don't call instance methods statically
Jul 25, 2017 @ 16:16:39

In this new post on thePHP.cc site they talk about calling instance methods statically, more specifically that it should be avoided.

There are quite a few things in PHP 4 that were a bit strange. One example is that PHP 4 allowed static calling of instance methods. [...] To keep backwards compatibility with PHP 4, this code works up to PHP 5, even though [the method in the example[ is not declared static.

[...] Now things will get really weird. When calling an instance method of another class statically, the $this context would carry over from the caller to the called class. In other words, $this suddenly refers to another object instance. While in PHP 5, this used to be an E_STRICT error, PHP 7 will emit an E_DEPRECATED error.

They point out that, while this is definitely odd behavior that shouldn't exist, it hasn't been removed because of PHP's backwards compatibility principles and only removing functionality like this in major versions. So, instead, they recommend calling all non-static methods using an instance of the class injected rather than directly calling them.

tagged: instance method call static object avoid error

Link: https://thephp.cc/news/2017/07/dont-call-instance-methods-statically

Liip Blog:
Testing in the Cloud – Using Bamboo with Amazon AWS
Jun 08, 2016 @ 19:51:19

On the Liip blog there's a new post showing you how to set up "testing in the cloud" with the help of AWS and a Bamboo instance along with some custom configuration.

Bamboo is the continous integration service by Atlassian, the company owning the code management service Bitbucket (as well as the Jira issue tracker and Confluence wiki). Bamboo can run test suites and build any kind of artefact like generated documentation or installable packages. It integrates with Amazon Web Services, allowing to spin up EC2 instances as needed.

The article talks about the permissioning needed for the EC2 AWS instances and how to trigger automatic builds. They then get into the details of configuring the test runner and the PHPUnit setup to allow for the execution of your tests.

tagged: testing cloud aws bamboo amazon ec2 instance atlassian

Link: https://blog.liip.ch/archive/2016/06/08/testing-cloud-using-bamboo-with-amazon-aws.html

Zend Blog:
Running Zend Server on Google Cloud Platform
Oct 30, 2015 @ 15:46:49

On the Zend blog there's a recent post showing you how to run Zend Server on the Google Cloud Platform, an easy to use service that makes deploying new sites a few clicks away.

Day 1 at ZendCon in Las Vegas has seen some pretty interesting announcements, one of them being the availability of Zend Server on Google’s Cloud Platform. Just in case you want to check it out, this article will help you get started.

Google’s Cloud Platform boasts a highly-scalable and reliable infrastructure, with computing, storage and application services for developing, testing and deploying your apps. With Zend Server, you get a certified and secure PHP stack, advanced development tools which include Z-Ray, and a bunch of additional features to aid your development workflow. Taken together, you get a powerful development setup.

They walk you through the simple process you'll need to follow to get the Zend Server instance up and running, complete with screenshots. They help you create the instance, create the server password and launch the result.

tagged: zendserver google cloudplatform deploy virtualmachine instance tutorial

Link: http://blog.zend.com/2015/10/20/running-zend-server-on-google-cloud-platform/

Zend:
Debugging WordPress with Zend Server and Z-Ray on AWS
Aug 05, 2015 @ 16:57:02

The Zend.com blog has a post showing you how to debug WordPress running on Zend Server with the help of the Z-Ray plugin. In their example they're hosting it on an AWS instance, but the same technique can apply on any other hosted version as well.

More and more PHP development is being done in the cloud and on virtual platforms nowadays. The workflow detailed in this brief tutorial is just one way to develop PHP in these environments, but it illustrates just how easy and productive this type of development can be. More specifically, it demonstrates how to launch the newly available Zend Server 8.5 instance on AWS with a WordPress application already deployed, and then use Z-Ray to introspect and debug the code.

The tutorial walks you through the setup and configuration of a new AWS instance with Zend Server and WordPress installed (you can skip to the end if you already have this). They show you how to:

  • Launch the Zend Server AWS instance
  • Configure the instance to install WordPress as a part of the setup process
  • Access the Zend Server control panel
  • Accessing the WordPress application deployed on the instance

Once the WordPress application is accessed, the Z-Ray inspection bar will appear at the bottom giving you insight into various configuration options, performance metrics and server information. They also link to a video with more information about the WordPress plugin.

tagged: zendserver wordpress aws amazon instance zray debug tutorial install configure

Link: http://blog.zend.com/2015/08/04/debugging-wordpress-with-zend-server-and-z-ray-on-aws

Drupalize.me:
Learning Drupal 8 from Boilerplate Code
Jul 30, 2015 @ 16:48:06

On the Drupalize.me site they've posted a guide to getting started with Drupal 8 based on the boilerplate code that already comes with the release.

Drupal 8 represents a lot of changes and a steep learning curve for many Drupal developers and themers. While many of these changes are exciting, there are many things to learn just to get started. One way to learn about the code involved with Drupal 8 modules and themes is to take a look at core's modules and themes for examples to follow. Another is to use a code-scaffolding tool like Drupal Console to generate boilerplate code and comments that you can learn from and then customize.

He makes the assumption that you already have a development environment set up and working then helps you install the Drupal Console for use in the rest of the tutorial. You can then use this command line tool to create a new Drupal 8 installation and generate the boilerplate code for a new theme. Finally, they show the creation of the two other related components: a new module and a block plugin instance. These are generate generic code you can use as a reference point for either updating your current Drupal projects or create new ones.

tagged: drupal8 commandline console instance theme plugin block installation

Link: https://drupalize.me/blog/201507/learning-drupal-8-boilerplate-code

X-Team Blog:
Automated Deployment in 90 minutes with Docker, AWS and Codeship
Jul 08, 2015 @ 15:22:27

In the X-Team blog they've posted about deployment, specifically combining Docker and Codeship to push an application (in this case a Symfony2 one) out to an Amazon Web Services instance.

Just imagine. It’s Friday afternoon, the team has just finished a new feature which should be deployed to the servers before the weekend. And you are the lucky guy who is responsible for completing the task. Generally, it shouldn’t take more than five minutes. Well, what could possibly go wrong. [...] In the attached video, you’ll find an introduction on how to setup and automate deployment with Docker, AWS Elastic BeansTalk and Codeship in 90 minutes. Don’t miss a Friday night party ever again!

The tutorial comes in the form of a video screencasting the whole process, all the way from setting up the AWS instance and Codeship account out to the configuration and software you'll need to use Docker to build the containers and make the deploy.

tagged: automation docker codeship aws instance tutorial screencast elasticbeanstalk

Link: http://x-team.com/2015/07/automated-deployment-90-minutes-docker-aws-codeship/

NetTuts.com:
Using the Digital Ocean API to Manage Cloud Instances
Jun 05, 2015 @ 16:14:10

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.

tagged: digitalocean manage cloud instance sdk tutorial yii2

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

7PHP.com:
Installing Magento version 2 on an AWS (Amazon) Free Tier EC2 Instance On LEMP
May 28, 2015 @ 13:58:05

The 7PHP.com site has a tutorial they've recently posted showing you how to get Magnto 2 installed on an AWS instance running LEMP (Linux, Nginx, MySQL and PHP).

This article tries to demonstrate how to setup an AWS (EC2) instance, installing a LEMP stack, preparing the server environment to meet Magento’s requirements and then to finally install Magento v2 using command line approach. [...] I’m presenting in this article something which might otherwise seem to be a daunting approach – but I also see it as an approach which you can later automate by using Docker/Dockerfile for example or even using a Vagrant appliance.

He takes you through the entire process, including the setup of the account and instance on the AWS side, with screenshots along the way:

  • Creating a Free Tier AWS Account
  • Preparing & Configuring your AWS EC2 Instance
  • Creating A Security Group For Our AWS EC2 Instance
  • Creating a PEM file – Key Pairs
  • Creating our AWS EC2 Instance
  • Creating an Elastic IP & Assigning to our EC2 Instance
  • Preparing & Configuring our AWS EC2 Instance
  • Installing Our LEMP Stack
  • The Magento 2 Project Installation Walkthrough
  • Configuring nginx conf file to serve our magento site
  • Creating a database & running The Magento Setup From Commandline

You'll find all the commands, screenshots and output examples you'll need to follow along with the tutorial easily. There's also links to other resources if you're interested in finding out more about the setup.

tagged: commandline magento2 aws ec2 instance install tutorial stepbystep

Link: http://7php.com/installing-magento-v2-aws-ec2-commandline/

Semaphore CI Blog:
Deploying PHP Applications with Rocketeer and Docker
Apr 10, 2015 @ 16:52:08

The Semaphore CI blog has a new tutorial showing you how to use Rocketeer and Docker to deploy PHP applications, pushing the resulting application out into a Docker container.

Deploying web applications is an integral part of modern web development. From this need, many tools have emerged to make the process as easy as possible. Rocketeer is heavily influenced by Capistrano and Laravel's principle of elegant code. It strives to make the deployment process accessible for everyone. [...] We'll deploy a fresh Laravel installation to a running Docker instance. This enables us to focus on setting up and using Rocketeer while the Docker instance will act as an application server requiring zero configuration and a great environment to experiment with.

They start with a list of requirements you'll need before getting started including Docker running on the server and Composer. They help you get Rocketeer installed and using the Docker command line too to set up and configure the server. Next up they show you how to use the "rocketeer" command to configure the Laravel application to be deployed. Once configured, they show you what updates you'll need to make and, finally, how to run the deployment. They also "dig deeper" and look at the file system setup on the server, stages of deployment, tasks, strategies and plugins.

tagged: tutorial deploy laravel application rocketeer docker instance

Link: https://semaphoreci.com/community/tutorials/deploying-php-applications-with-rocketeer-and-docker


Trending Topics: