APC as a session handler using Symfony components - php

I'm using Symfony components in my web application. I need to store session in APC but unfortunatelly I can't find the way to do it.
As I see here Symfony does not support APC as a session handler. Is that true?
I have found an old example of using APC as a session handler in Symfony. But there all configuration is done in factories.yml file which I don't have since I'm only using standalone Symfony components.
Can anyone give me an example of using APC as a session handler using only Symfony components?

Since I don't get any answer here for a long time I will answer the question myself. For now there is no built in suport for APC as a session handler in Symphony framework. There is no particlar reason for it, likely Symphony developers just did not get to it.
The solution is simple, just code APCSessionHandler.php file yourself (I was not doing it because we decided not use this in project), APCSessionHandler will be very similar to MemcachedSessionHandler.php file.

How to store PHP sessions in APC Cache? suggests it is feasible but a bad idea for a busy site. The accepted answer lists a few useful ideas

Related

How to load 2 controllers from different codeigniters?

I'm trying to access the controller from another CodeIgniter.
I have a CodeIgniter 3.0.4 that containing:
Application
codeigniter2
css
js
...
so I have already tried $this->load->library('../controllers/home'); ,
but it shows me the Unable to load the requested class: Home
And I'm trying to login to both at the same time so I need to access each Session
I would strongly suggest that you simply either import the required library or combine both apps into the latest CI 3.1 as there have been several security fixes plus many more bug fixes. Upgrading from 2.x to 3.x is usually a very simple task.
However, you will not be able to use the CI loader to load a controller or library outside the normal directories, and you will not be able to share sessions across them either, as both sessions will have a different format for their session tables.
At a push, you might be able to create a bridge library, that includes the files you want, from the older CI version, but to be honest, unless the libraries you are connecting to are completely empty of any CI references, more like functional helpers rather than libraries, it just is not going to work, or would take far more work to achieve that it would to just upgrade and combine your old system. The advantages of doing that far outweigh the problems you are going to face with a bridging mechanism.
Sorry if that is not a lot of help, but in short, combine them into one app and upgrade to the latest version ASAP.
Best wishes,
Paul.

How to activate sessions in LUMEN 5.2

Im new to Lumen and i need to use the Session functionality, but based on the change log in the site. Sessions was excluded in the latest release, I already looked up in the documentation of Lumen 5.2, it says that i should refer to Laravel way of activating session and something like that. my problem is I have no experience using in Laravel too. Can anyone tell me, a step by step way to activate Lumen Sessions?
or can anyone suggest a third-party library?
There is no built-in session support in Lumen. From the release notes:
... sessions and views are no longer included with the framework. If you need access to these features, you should use the full Laravel framework.
You should install the Laravel framework instead of Lumen and refer its docs on sessions.
Also, the default PHP sessions are still available.

Output Cache and Redis?

I'm trying to implement the whole page cache in my website. (Just like stackoverflow). I have already implemented the Output Cache, but my friend told me that stackoverflow uses redis as their cache layer and I'm confused about the redis part.
Is redis the same as outputcache? Can I implement outputcache by using redis? (For yii developers, I'm using Yii's outputcache).
Thanks!
Yii's output cache will store the cached content using the active cache component, which can be CDummyCache/CDbCache/CApcCache/CFileCache/CMemCache, etc(what you set in the config file under the components area).
As it stands right now, there is no official CRedisCache component, but there is this extension: http://www.yiiframework.com/extension/rediscache/ which might help you.
Also, since Redis is key/value store and a bit more(though you won't use that bit more at all i guess) you can give CMemCache a try(having in mind you have memcache php extension and memcached daemon installed on your server).
L.E: i also found this for you: https://github.com/phpnode/YiiRedis which seems very neat.

Symfony 2 and Twig cache — are they the same?

My question is are the Symfony 2 cache mechanism and Twig cache mechanism the same?
Lets say I decide to use Twig in my MVC framework, would I have the same cache mechanism Symfony 2 uses? I know both Symfony2 and Twig are created by Fabien. But I dont know is Symfony 2 using only Twig cache or is there something more?
So I hope you understand the question. Does Symfony 2 uses Twig for cache? And if not, what are the differences between Symfony 2 and Twig caching?
unsure of the full answer, but symfony and twig must use separate caching mechanisms as you are not forced to use twig in symfony and yet cache still works. for more info check http://symfony.com/doc/current/ and dig into the code.
Edit:
To expand on my non-answer above. Twig cache is really a compilation cache. Your templates are saved as php files. To quote F. Potencier "[...] Twig caches the compiled templates to avoid the parsing phase for sub-sequent requests. [...]" (source)
While Symfony cache is (as has already been mentioned) a HTTP cache and is extensively explained in Symfony Docs cache section
Hope this helps.
Symfony 2 uses HTTP cache for caching purposes. And Twig cache is joust caching of Twig templates, so they don't have to recompile on every request. So Twig caching only ensures templates are compiled once on first request.
And Symfony 2 HTTP cache is another beast :) It provides abstraction around HTTP Cache mechanism and so you can cache using HTTP Cache headers etc...
So the short answer is NO! They are not the same!
No, they are not the same. Symfony caches a lot of stuff like routes, translations, the container, etc; Twig just caches templates by compiling them down to PHP classes. Of course, Twig's caching system works in a Symfony app as well.

How to enable PHP native sessions in codeigniter?

I'm trying to integrate Facebook's API in a CodeIgniter project, however it seems to be not working because sessions are disabled somehow in CodeIgniter. (Trying to integrate outside CodeIgniter works, but inside a codeigniter project it doesn't work).
Is there any way to do this? All I want is for native sessions to not be cleared or destroyed by CodeIgniter. If the only way is to hack the core to remove a line or two, then I'm willing to do it. I think there's someplace where its doing $_SESSION = null or something like that. Where's this place, so I can remove that line?
If you follow this blog on a fresh CI install, it works without any problem:
http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/
From there, you can continue to build you application, or find where it goes wrong.
in CI session are not disabled.
It must be done in your manual coding.
Please refer your coding again.
It is also possible that some jQuery - JS is conflicted in project, which can destroy session.
There is a library to extend CI sessions (which are cookies) to use native server sessions.
Have a look at this native session library.

Categories