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

Martin Hujer:
Have you tried Composer Scripts? You may not need Phing.
Jan 15, 2018 @ 17:14:13

In a new post to his site Martin Hujer shows you that, with the help of the "script" ability in Composer, you may not need a build tool like Phing. The scripts functionality allows you to execute custom scripts as a part of the Composer workflow, enhancing the management functionality it already provides.

Phing is a great tool (I'm using it as well), but in this article, I want to show you that some projects may not need it. Composer contains a powerful feature called "Scripts", which can be used to create a simple build script.

In his example, he shows how to integrate a run of the PHP_CodeSniffer quality assurance tool as a part of your Composer configuration. This makes it possible to run a command like composer run-script phpcs and automatically run the checks. He then builds on this simple example and creates a more complex build script that still runs PHP_CodeSniffer but also executes PHPUnit tests. He post also shows how to run Composer in a command and how to document each command. There are also a few handy tips included around running Composer on Windows, listing the current scripts and executing custom callbacks to code.

tagged: composer build scripts tutorial example phing phpcodesniffer phpunit

Link: https://blog.martinhujer.cz/have-you-tried-composer-scripts/

Exakat Blog:
Prevent multiple PHP scripts at the same time
Dec 16, 2016 @ 17:09:23

The Exakat.io blog has a post with an interesting method for preventing the execution of multiple instances of a script at once - locking execution with an external indicator (like files, semaphores and streams/sockets).

Like everything, it all started from a simple problem : how to prevent multiple PHP scripts at the same time. And turned into an odyssey of learning, full of evil traps and inglorious victories. In the end, it works, that’s the most satisfying and it possibly matters to no one except me. But "the way is the goal", as said Confucius, so, I decided to share the various findings.

Exakat runs in command line, and it uses a graph database. The database is central to the processing, and it is crucial to avoid running several scripts at the same time : they will write over each other. So, the problem is simple : preventing several instances to run at the same time, on the database. In commandline, there is no web server that may serve as common place between scripts, sharing some memory and implementing a locking system. It requires to use another common ground : the system.

He shares some of the methods he tried to help prevent the simultaneous execution of the Exakat process including:

  • file locking using flock
  • creating a "lock" file
  • making it "crash proof"
  • using semaphores
  • using a socket for the lock

He describes some of the issues he found when running the tool using locking inside of a Docker container and, finally, the use of sockets and streams to place a "hold" until the script closes (also preventing issues on a crash). He ends the post talking about the "final boss" in his battle for locking support - the handing off of the socket connection to another process between parent and child. The final list in the post is a list of each method he tried, their benefits and downsides (but only in certain situations).

tagged: exakat prevention multiple scripts locking execution solutions

Link: https://www.exakat.io/prevent-multiple-php-scripts-at-the-same-time/

Master Zend Framework:
How To Automate Projects Using Composer Scripts
Dec 06, 2016 @ 18:08:01

The Master Zend Framework site has posted a new tutorial showing you how to automate your projects with Composer, making use of the "scripts" section to add commands that can be automatically executed via a "composer" command line call.

Here, in the second part of the series, we’ll look at the scripts section of composer.json. If you’ve never heard of this section, it provides a way to automate tasks in your project.

Perhaps you think that this is unnecessary, as there is already such a wealth of tools available; including Make, Ant, Phing, and so on. But I see a place for having automation in Composer — though at first I didn’t.

Why? Because you can bring everything that much closer together. Because you can keep everything in a very tidy, organized, and well-structured way.

He starts with a brief overview of how the "scripts" section of the composer.json configuration works. He also shows examples of setting up scripts for code sniffing, running tests and generating test coverage reports. He also shows how to run these commands via the Composer command line and an the use of event handlers (like "post-install-cmd") to execute things at a certain point in the install/update process. He finishes off the post with an example from Zend Expressive calling an "Automation" to clear out the contents of the caches.

tagged: automate composer project scripts configuration tutorial event

Link: http://www.masterzendframework.com/series/tooling/composer/automation-scripts/

Loïc Chardonne:
Symfony Differently - part 2: Bootstrap
Jun 16, 2015 @ 15:46:03

Loïc Chardonne has posted the latest part in his "Symfony Differently" series (part one is here) with a focus on bootstrapping the application and configuring the environment that it will live in.

Our goal in this post is to bootstrap an application to then create a search endpoint for items. We've decided to use Symfony for a single reason: our company Acme used it since the beginning and the API developers team has Symfony and PHP skills.

He walks through the steps you'll need to get the application up and running:

  • Creating a new Symfony Standard Edition project
  • Configuring Apache
  • Moving the tests to a different directory, including Composer updates
  • Creating scripts for builds, testing and deployment

With all this structure in place, the next part of the series will start in on the functionality of the search endpoint and returning the results.

tagged: symfony bootstrap differently tutorial series part2 project apache scripts tests

Link: http://gnugat.github.io/2015/06/10/sf-differently-part-2-bootstrap.html

NetTuts.com:
More Tips for Best Practices in WordPress Development
Jul 25, 2014 @ 14:18:09

NetTuts.com has published a few more WordPress tips and best practices to help you get the most out of your WordPress-based application.

Welcome to the second part of the series. In the first article, we explained the WordPress Coding Standards, how to avoid namespaces collisions, comments in the code, and some basic security tips. Today, we are going to go a bit deeper and write some more code and learn some techniques to improve performance and security of our plugins.

They look specifically at when you should include your scripts and styles, formatting Ajax calls and working with filters and actions. Code snippets are included with each point with links to some other resources for some of the topics to provide more information.

tagged: wordpress bestpractices development ajax scripts styles filters actions

Link: http://code.tutsplus.com/articles/more-tips-for-best-practices-in-wordpress-development--cms-21013

KnpLabs Blog:
Composer Level2: 5 more things like Class Maps, Forking, & Scripts
Nov 08, 2012 @ 15:17:14

On the KnpLabs blog there's a new post from Ryan Weaver sharing some cool things you can do with Composer you might not have known about when managing your application's dependencies.

For those of you that are comfortable with Composer, I wanted to talk about a few lesser-known, but really fantastic features. These are inspired by real questions I've heard while running around the country doing my one-man composer-and-dancing show (i.e. conference talks).

He shares four of them with a fifth that's more of an "upcoming feature" than a current one:

  • Autoloading & Performance: "I thought class maps were the fastest?"
  • Running Post-Deploy Scripts
  • "What if I need to fork a library?"
  • Can I host private packages on Packagist?
  • What about signing the authenticity of Packages?

That last one about package signing is still on the known issues list and is under discussion, but no doubt that future versions of the tool will support it.

tagged: composer classmap forking scripts package signing

Link:

Community News:
PerlCoders and PHP Labs Marge (with Promotion)
Sep 12, 2006 @ 21:09:24

According to this new press release, PerlCoders and PHP Labs have joined forces and become one and, to share the love with others, they're offering discounts on their offerings.

Over the last week, PerlCoders and PHP Labs have merged to offer even more professional scripts to their clients. To celebrate this merger, they are now offering a one-time special promotion for webmasters, which can save them over $300. As a small incentive for new members, PHP Labs is also offering free installation for the first script of your choice.

The press release goes on to talk about what each is bringing to the table and what they're offering from now on. The $300 promotion goes towards a membership for the site, giving you access to all 44 scripts without paying extra. Examples of the scripts include GalleryMaker, ProxyCheck, FileMailer, and CashMail. You can get more information from the promotion's page on their website.

tagged: perlcoders labs promotion deal scripts access perlcoders labs promotion deal scripts access

Link:

Community News:
PerlCoders and PHP Labs Marge (with Promotion)
Sep 12, 2006 @ 21:09:24

According to this new press release, PerlCoders and PHP Labs have joined forces and become one and, to share the love with others, they're offering discounts on their offerings.

Over the last week, PerlCoders and PHP Labs have merged to offer even more professional scripts to their clients. To celebrate this merger, they are now offering a one-time special promotion for webmasters, which can save them over $300. As a small incentive for new members, PHP Labs is also offering free installation for the first script of your choice.

The press release goes on to talk about what each is bringing to the table and what they're offering from now on. The $300 promotion goes towards a membership for the site, giving you access to all 44 scripts without paying extra. Examples of the scripts include GalleryMaker, ProxyCheck, FileMailer, and CashMail. You can get more information from the promotion's page on their website.

tagged: perlcoders labs promotion deal scripts access perlcoders labs promotion deal scripts access

Link:

Builderau.com.au:
Cache PHP scripts with APC module
Sep 06, 2006 @ 11:49:10

On the Builder AU site, there's this quick look at using the APC module (a PECL package) to help speed up your applications.

Looking to get every ounce of performance from your Web server? If you're using PHP scripts, you can easily accomplish this using PHP's APC module, which caches php opcode instead of forcing php to reinterpret every script every time it is executed.

The install is simple (on PHP5) and they show some configuration options you can use to fine-tune the performance of the module to fit your needs. There's also a brief look at what the module actually does to the scripts as they get interpreted and passed out of PHP and into the web server.

tagged: apc cache scripts module pecl install configure tutorial apc cache scripts module pecl install configure tutorial

Link:

Builderau.com.au:
Cache PHP scripts with APC module
Sep 06, 2006 @ 11:49:10

On the Builder AU site, there's this quick look at using the APC module (a PECL package) to help speed up your applications.

Looking to get every ounce of performance from your Web server? If you're using PHP scripts, you can easily accomplish this using PHP's APC module, which caches php opcode instead of forcing php to reinterpret every script every time it is executed.

The install is simple (on PHP5) and they show some configuration options you can use to fine-tune the performance of the module to fit your needs. There's also a brief look at what the module actually does to the scripts as they get interpreted and passed out of PHP and into the web server.

tagged: apc cache scripts module pecl install configure tutorial apc cache scripts module pecl install configure tutorial

Link:


Trending Topics: