-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why autoload param disabled for class_exists in Compiler.php ? #115
Comments
This is because AOP class is not compiled yet. Related with #114 . I will explain how to boost the performance in README. |
Simple patch fix this issue: Index: vendor/ray/aop/src/Compiler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/ray/aop/src/Compiler.php (date 1574169214940)
+++ vendor/ray/aop/src/Compiler.php (date 1574169214940)
@@ -76,7 +76,7 @@
return $class;
}
$aopClassName = $this->getAopClassName($class, $bind);
- if (class_exists($aopClassName, false)) {
+ if (class_exists($aopClassName, true)) {
return $aopClassName;
}
$this->requireFile($aopClassName, new ReflectionClass($class), $bind); Can you explain or give examples in which the false argument really is needed here? |
Did you confirm the autoloader works ? |
I'm still waiting an explanation about caching. But #116 seems to be simple and fundamental solution for me, so closed mine #114. I confirmed that this is working correctly using "autoload": {
"classmap": [
"path/to/compile/directory"
]
}, |
It compiles only when the annotations are changed. it works well. |
My original thought is class compile / cache is handled by "upper layer" like DI container or factory code. Compiler should be called only when it really needed, Like first appearance, Not on every request. But yes, I will try with your solution but with better autoloading. ("classmap" needs |
This is designed by package https://github.com/ytake/Laravel-Aspect I created issue ytake/Laravel-Aspect#63 I do not know how good this solution is and whether it can be improved. |
Umm... Seems too much job on runtime. |
<?php
namespace Ray\Aop;
function class_exists(string $class)
{
return \class_exists($class, true);
} This function is just a quick hack... |
I pushed #117. |
( ̄ω ̄;)╭ -> New |
Closed. Please use |
Case: I use composer and every request your library recompiled all classes.
Ray.Aop/src/Compiler.php
Line 79 in 8dcf395
ytake/Laravel-Aspect#63
The text was updated successfully, but these errors were encountered: