laravel-async-queue
laravel-async-queue copied to clipboard
Weird behaviour in including
Hi,
I have this class which i included in composer.json:
"files": ["app/lib/coolstuff/A.class.php"]
A.class.php:
<?php
require_once 'functions.php';
class A
{
public function __construct()
{
if (function_exists('foobar')) {
file_put_contents("log.txt", "yes");
}
else{
file_put_contents("log.txt", "no");
}
}
}
And functions.php :
function foobar(){
// do something complicated
}
when using async, function foobar isn't defind but functions.php is included ( using get_included_files ) log.txt has "no" , log.txt path is root path
when using sync driver, foobar is defined and log.txt has "yes" , log.txt path is public_path
I don't now, can you include the full absolute path?
Hi,
/Applications/MAMP/htdocs/test/app/lib/coolstuff/A.class.php
/Applications/MAMP/htdocs/test/app/lib/coolstuff/functions.php
/Applications/MAMP/htdocs/test/log.txt
/Applications/MAMP/htdocs/test/public/log.txt
I mean in Your code, instead of the relative ones.
Ah sorry, tried that.. same issue. Files are being included but functions arent being defined. Same code works fine with sync driver
Why not autoload the functions file with composer also? Sync is different, that runs in the same request so has access to everything that is already loaded in that request cycle. Async is a entirely new request.
Project i'm on has seven or eight files, would be kinda messy. Shouldn't Laravel helpers be defined too ?