Skip to content

Instantly share code, notes, and snippets.

@daniel-sc
Last active November 10, 2015 08:15
Show Gist options
  • Save daniel-sc/2dc6f04dc605c14c2308 to your computer and use it in GitHub Desktop.
Save daniel-sc/2dc6f04dc605c14c2308 to your computer and use it in GitHub Desktop.
Reproducing goaop classloading error in shutdown function

Build

(analogous for Dockerfile-php5-4and Dockerfile-php5-6).

composer install
docker build -t aop-shutdown -f Dockerfile-php5-5 .

Run

docker run aop shutdown-baseline.php
docker run aop shutdown-with-goaop.php
{
"require": {
"phpmailer/phpmailer": "5.2.*",
"goaop/framework": "*"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "b6fb1719d5f17cf934b7ba7ad5a76141",
"packages": [
{
"name": "andrewsville/php-token-reflection",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/Andrewsville/PHP-Token-Reflection.git",
"reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Andrewsville/PHP-Token-Reflection/zipball/e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee",
"reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"TokenReflection": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3"
],
"authors": [
{
"name": "Ondřej Nešpor",
"homepage": "https://github.com/andrewsville"
},
{
"name": "Jaroslav Hanslík",
"homepage": "https://github.com/kukulich"
}
],
"description": "Library emulating the PHP internal reflection using just the tokenized source code.",
"homepage": "http://andrewsville.github.com/PHP-Token-Reflection/",
"keywords": [
"library",
"reflection",
"tokenizer"
],
"time": "2014-08-06 16:37:08"
},
{
"name": "doctrine/annotations",
"version": "v1.2.7",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "4.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\Annotations\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
],
"time": "2015-08-31 12:32:49"
},
{
"name": "doctrine/lexer",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\Lexer\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"lexer",
"parser"
],
"time": "2014-09-09 13:34:57"
},
{
"name": "goaop/framework",
"version": "0.6.1",
"source": {
"type": "git",
"url": "https://github.com/goaop/framework.git",
"reference": "4411e951d06d7041e3128fefd6fe6a0a344cd1ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/goaop/framework/zipball/4411e951d06d7041e3128fefd6fe6a0a344cd1ba",
"reference": "4411e951d06d7041e3128fefd6fe6a0a344cd1ba",
"shasum": ""
},
"require": {
"andrewsville/php-token-reflection": "~1.3",
"doctrine/annotations": "~1.0",
"jakubledl/dissect": "~1.0",
"php": ">=5.3.0"
},
"require-dev": {
"symfony/console": "~2.1"
},
"suggest": {
"symfony/console": "Enables the usage of the command-line tool."
},
"bin": [
"bin/warmup"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.6-dev"
}
},
"autoload": {
"psr-4": {
"Go\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Lisachenko Alexander",
"homepage": "https://github.com/lisachenko"
}
],
"description": "Library for aspect-oriented programming in PHP.",
"homepage": "http://go.aopphp.com/",
"keywords": [
"aop",
"aspect",
"library",
"php"
],
"time": "2015-07-05 11:37:33"
},
{
"name": "jakubledl/dissect",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/jakubledl/dissect.git",
"reference": "d3a391de31e45a247e95cef6cf58a91c05af67c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jakubledl/dissect/zipball/d3a391de31e45a247e95cef6cf58a91c05af67c4",
"reference": "d3a391de31e45a247e95cef6cf58a91c05af67c4",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/console": "~2.1"
},
"suggest": {
"symfony/console": "for the command-line tool"
},
"bin": [
"bin/dissect.php",
"bin/dissect"
],
"type": "library",
"autoload": {
"psr-0": {
"Dissect": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"unlicense"
],
"authors": [
{
"name": "Jakub Lédl",
"email": "jakubledl@gmail.com"
}
],
"description": "Lexing and parsing in pure PHP",
"homepage": "https://github.com/jakubledl/dissect",
"keywords": [
"ast",
"lexing",
"parser",
"parsing"
],
"time": "2013-01-29 21:29:14"
},
{
"name": "phpmailer/phpmailer",
"version": "v5.2.13",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "45df3a88f7f46071e10d0b600f228d19f95911b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/45df3a88f7f46071e10d0b600f228d19f95911b3",
"reference": "45df3a88f7f46071e10d0b600f228d19f95911b3",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "*",
"phpunit/phpunit": "4.7.*"
},
"suggest": {
"league/oauth2-client": "Needed for Gmail's XOAUTH2 authentication system"
},
"type": "library",
"autoload": {
"classmap": [
"class.phpmailer.php",
"class.phpmaileroauth.php",
"class.phpmaileroauthgoogle.php",
"class.smtp.php",
"class.pop3.php",
"extras/EasyPeasyICS.php",
"extras/ntlm_sasl_client.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
},
{
"name": "Brent R. Matzelle"
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2015-09-14 09:18:12"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
FROM php:5.4-cli
COPY . /
ENTRYPOINT ["php"]
CMD ["/shutdown-with-goaop.php"]
FROM php:5.5-cli
COPY . /
ENTRYPOINT ["php"]
CMD ["/shutdown-with-goaop.php"]
FROM php:5.6-cli
COPY . /
ENTRYPOINT ["php"]
CMD ["/shutdown-with-goaop.php"]
FROM php:7-cli
COPY . /
ENTRYPOINT ["php"]
CMD ["/shutdown-with-goaop.php"]
<?php
// see https://github.com/Codeception/AspectMock/issues/31
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
require_once __DIR__ . '/vendor/autoload.php';
class MyAspectKernel extends AspectKernel
{
protected function configureAop(AspectContainer $container)
{
}
}
register_shutdown_function(function () {
echo "shutdown function..\n";
$mailer = new PHPMailer(); // required via composer autoload
echo "done.\n";
});
exit;
<?php
// see https://github.com/Codeception/AspectMock/issues/31
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
require_once __DIR__ . '/vendor/autoload.php';
class MyAspectKernel extends AspectKernel
{
protected function configureAop(AspectContainer $container)
{
}
}
MyAspectKernel::getInstance()->init([
'includePaths' => [__DIR__]
]);
register_shutdown_function(function () {
echo "shutdown function..\n";
$mailer = new PHPMailer(); // required via composer autoload
echo "done.\n";
});
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment