We're using symfony2 with php 5.6.
With default config we can cache validation metadata:
framework:
validation:
cache: apc
How can we use this with PHP 5.6 and built in OpCache?
In default app.php we can cache the class autoloader:
if (extension_loaded('apc')) {
$apcLoader = new ApcClassLoader('foo', $loader);
$apcLoader->register(true);
}
How can we achieve the same using Zend OpCache? We tried with UniversalClassLoader but we are not shure, if this is right.
In default config we can use apc also for caching doctrine metadata, dql, and so on:
doctrine:
orm:
metadata_cache_driver: apc
result_cache_driver: apc
query_cache_driver: apc
Is there a way to cache metadata, result and query stuff with propel instead of Doctrine?
The Opcache built into recent PHP versions doesn't provide APC-like user storage - it's just for the bytecode caching. You can install ApcU, to use the APC cache driver, but otherwise, you'll want to select a different cache mechanism.
It won't be so much of an issue for the ClassLoader, since that is already handled by Composer optimisation and the Opcache, but will be useful for the other caching.
Related
The Doctrine\DBAL\Event\Listeners\OracleSessionInit was deprecated in DBAL 3.5 (https://github.com/doctrine/dbal/blob/3.5.x/UPGRADE.md) in favor of the Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession.
How should I setup the application with a new middleware? The documentation (https://symfony.com/bundles/DoctrineBundle/2.4.x/configuration.html#oracle-db) still show an old way.
I tried to use driver_class and wrapper_class options, but it does not work.
Laravel Version: 5.8.11
PHP Version: 7.1.26 (Homestead) - but also tested with 7.2 with same result
Since updating from 5.7 to 5.8, I can't resolve an instance anymore. It returns a string and I get Trying to get property of non-object.
Steps To Reproduce:
I bind the instance in a Middleware with:
$globals = new Globals();
app()->instance('App\Helpers\Globals', $globals);
$globals->brows_browser = Agent::browser();
when trying to resolve it later (for example in web.php) with:
$browser = resolve('App\Helpers\Globals')->brows_browser;
I get an error exception Trying to get property of non-object. $browser is a string "Helpers\Globals" and not an object. Was working fine in all Laravel versions before.
namespace App\Helpers;
class Globals
{
public $brows_browser;
public $brows_device;
public $brows_platform;
public $brows_version;
}
I also tried to bind the instance in the route (web.php) and it produced the same result.
When I look at resolve('App\Helpers\Globals'), it is a string "App\Helpers\Globals" and not an object.
Anyone any idea? Could this be a bug in L5.8?
thanks
UPDATE:
It is not a bug.
I have goetas-webservices/xsd2php-runtime installed with composer and that's causing problems. I really have no idea why and what to do about it though.
These are the dependencies installed. I'm a bit at a dead end as I need that package:
Package operations: 17 installs, 0 updates, 0 removals
- Installing jms/metadata (2.0.0): Loading from cache
- Installing hoa/exception (1.17.01.16): Loading from cache
- Installing hoa/event (1.17.01.13): Loading from cache
- Installing hoa/consistency (1.17.05.02): Loading from cache
- Installing hoa/zformat (1.17.01.10): Loading from cache
- Installing hoa/protocol (1.17.01.14): Loading from cache
- Installing hoa/iterator (2.17.01.10): Loading from cache
- Installing hoa/visitor (2.17.01.16): Loading from cache
- Installing hoa/ustring (4.17.01.16): Loading from cache
- Installing hoa/compiler (3.17.08.08): Loading from cache
- Installing hoa/regex (1.17.01.13): Loading from cache
- Installing hoa/math (1.17.05.16): Loading from cache
- Installing hoa/stream (1.17.02.21): Loading from cache
- Installing hoa/file (1.17.07.11): Loading from cache
- Installing doctrine/annotations (v1.6.1): Loading from cache
- Installing jms/serializer (2.2.0): Loading from cache
- Installing goetas-webservices/xsd2php-runtime (v0.2.9): Loading from cache
jms/serializer suggests installing doctrine/collections (Required if you like to use doctrine collection types as ArrayCollection.)
Writing lock file
UPDATE 2:
I drilled further down and it seems that hoa/compiler (specifically hoa/stream) is incompatible with Laravel 5.8
hoa/compiler is a dependency of jms/serializer.
That really sucks because jms/serializer is irreplaceable for us!
It's not a Laravel bug but an incompatibility with hoa/compiler (specifically hoa/stream).
hoa/compiler is a dependency of jms/serializer.
So for the moment jms/serializer won't play nice with Laravel 5.8
simple bind like this in laravel 5.8 take care will be registered within service providers,
$this->app->bind('App\Helpers\Globals', function () {
return new App\Helpers\Globals();
});
You may use the make
$globals = $this->app->make('App\Helpers\Globals');
I enabled the ResponseCaching on my .net Core 2.1 WebApi using the MSDN Documentation:
https://learn.microsoft.com/en-us/aspnet/core/performance/caching/middleware?view=aspnetcore-2.1
It works correctly.
Now I want after an update, clear the cache globally.
Innocently, I thought using:
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
will clear automatically the cache but it s not the case.
How can I do that?
Thanks for your help
There really is nothing to “clear” in your case because this is cached on the client via headers in the response.
I think you are looking for something more of a data store like Redis to cache this response data. The way you are doing it now the browser will cache locally and there is no way for you to invalidate that on the client
I cannot get to disable cache in shared hosting. When I set
$f3->set('DEBUG', 3);
$f3->set('LOCALES', 'lang/');
$f3->set('AUTOLOAD', 'app/controllers/');
$f3->set('UI', 'app/views/');
$f3->set('CACHE', FALSE);
$f3->clear('CACHE');
$cache->reset();
Cache still working and I cannot properly debug
Thanks it was due to Zend OPcache module. All I need is to insert
php_flag opcache.enable Off into .htaccess file
I developed a website using Yii2 Framework, and while I didn't explicitly use the Cache features, I guess it does do some things using APC as default.
The client where I published the website had uninstalled APC, since it is deprecated since v5.5 and refuse to install the extension.
My client now keeps receiving an 'unable to load dynamic library - apc.so' every time they try to save or delete a record to the database, not read.
I tried to clear the cache sub folder under the runtime folder in hopes that the website will use whatever system is available, but the error still creeps up.
They are using opcache. How can I reconfigure yii to use opcache and prevent the inability to find apc.so error?
EDIT:
This is what I have under components.
'cache' => [
'class' => 'yii\caching\FileCache',
],
If your cache is properly configured you should find something like this in the configuration file:
'components' => [
'cache' => [
'class' => 'yii\caching\ApcCache',
],
],
Now, AFAIK OpCache does not require configuration on the code level so you don't have to replace this config with something OpCache specific but there are direct cache calls in your code (hence the error) so you may want to use some available cache component anyway. In case you don't want to use any new cache component and at the same time you don't want to remove cache calls in your code use DummyCache:
'cache' => [
'class' => 'yii\caching\DummyCache',
],
EDIT:
It looks like it is not a case of Yii 2 configuration, more like a PHP configuration. Look for "unable to load dynamic library - apc.so". Probably APC is still in the PHP configuration but the library has been removed.
Related questions:
https://serverfault.com/questions/623520/php-startup-unable-to-load-dynamic-library-usr-lib-php5-20100525-apc-so
PHP APC Error Loading apc.so
APC - Unable to load dynamic library