I'm very new to Redis and fairly new to Laravel so could use some pointers on this.
We have a legacy PHP application that stores sessions to Redis and I'm able to see it in Redis with the default naming convention, ie.: PHPREDIS_SESSION:1bd9ca87f5b606a35891c807857c2fde
We're moving towards a Laravel API framework and as a short-term hybrid solution we want the API layer to be able to recognize and work with the session that's already been created through the legacy application.
I've been making slow progress into understanding Redis and I can see the legacy system's entries in Redis from Laravel (if I connect with a blank prefix), but is there a way to cut through Laravel's specialized handling and have it load the same PHPREDIS_SESSION space?
I've orbited this so many times I'm wondering if I've missed something simple.
Ultimately I got this working simply by updating my .env file with:
REDIS_PREFIX=PHPREDIS_SESSION:
CACHE_PREFIX=
I was hoping to avoid that since it's kind of bleh, but it functions and I suppose a config file is better than forcing Laravel to act against the grain.
Laravel is now recognizing the session being stored by my legacy application and trying to load it. Now I just need to get de/serialization to sync...
Related
I was working with Silex and Doctrine ORM. To make my database queries faster, I wanted to have a caching of some sort.
I looked at PhpFastCache - which provides a good caching framework - but does not really integrate with Doctrine. The best part about this is that I can have a local cache independent of any external service - like memcached. Since I have a small site which is hosted on shared host, I cannot spend money on having a service on cloud.
I also looked at existing cache providers for Doctrine ORM and all of them use external cache service.
The last thing I know I would have to do is write a provider myself using the PhpFastCache, but just wanted to make sure that there is no alternative online that I can use. I have tried my best by searching online all day today, but I just wanted to make sure.
Just to add: I have looked at APC and Memcache, but I have my site on shared hosting, and I would need a dedicated hosting for installing the PECL modules for APC/Memcache :(.
Doctrine includes quite a few cache drivers that do not seem to be documented. There is not one for PhpFastCache, but there are two that cache directly to the filesystem. Check out FilesystemCache and PhpFileCache. You can see the full list in the repository.
If I had to guess, I'd say that FilesystemCache is what you want. It stores serialized data in a plain file. PhpFileCache stores it as a PHP file, and then uses include to read it later. That means it has to be parsed by PHP on read, which is probably slower unless you use a PHP bytecode cache like APC.
Neither solution will be as fast as something like Memcache since they both read from the filesystem instead of memory, but they should provide an optimization for slow database queries that are run often.
Edit: As Kiran Madipally pointed out, it should be easy create your own PhpFastCache driver by extending CacheProvider.
I quickly wrote a provider for PhpFastCache. I have added the gist here:
https://gist.github.com/thephoenics/ee7de9f95bfdf5f6c24f
I am creating a web application. I am fairly accustomed to Laravel and how it functions. I would like to know how I incorporate Ember into the Laravel setup. I am guessing public folder, but when I use Yeoman to install Ember into the public it involves the node_modules and gruntfile. My question is should all this be in the public folder (any security concerns?)
Some people say it is not good to mix the two. I would like multiple single page views so it makes sense. Plus it is a good challenge to get stuck into. I have researched any answers and had no luck.
You need to put your script files in your public folder, otherwise the clients browser wouldn't be able to fetch and use them. No security concerns there. That includes grunt, bower or any other files (if it happens that you need them in your production server).
We at work use Laravel and Ember. Ember is our true front end and Laravel is our true back end. It is a very good idea to use them together. It's also a good idea to start with multiple apps so you don't get overwhelmed in no time. In time, you can evolve to one huge app and/or you'll start writing components and mixins you can reuse across your apps.
Just a note: I use a combination of bootstrapped data (json_encoded in .blade views) and data fetched from the server via getJSON (I don't currently use Ember Data because is not production ready yet)
I hope this helps you!
I have a really nasty problem with a CodeIgniter application which I want to load balance using also MySQL replication.
In other PHP frameworks this would be a 5minute job because you may switch the datasource just before saving the data (CakePHP allows this, for example), but it seems in CodeIgniter that's a different story.
My problem is the application is legacy and I have to load balance it so I have all the hardware setup already done, the filesystem is in sync, the database has a slave and updates it as it should, but I have to make the second CodeIgniter application to read from the slave and write to the master.
I already found a solution but since the application is legacy I wouldn't want to go into its internals because I could destroy something that already works (it's also pretty sensible because people are paying within the app and it's also live which makes things even worse).
The solution I've found is this one which makes you change all the models in the application.
As further information CodeIgniter database driver (CI_DB_mysql_driver in this case) doesn't have any method for switching the connection or something.
Do you have another suggestion for tackling this problem? (besides changing all the models which I find a bit too intrusive)
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.
I'm thinking in create a webapplication with cakephp but consuming python's appengine webservice. But, to install cakephp etc, I need to configure the database. Appengine uses another kind of datastorage, with is different from mysql, etc.
I was thinking in store the data in appengine, and using the python webservices, and with the cakephp application comunicating with the webservice, for insert and retrieve data.
Is there any good resource for this, or is it unpossible.
Obs: also opened for a possibility for developing the webapplicaiton completely in python running in appengine. If anyone has a good resource.
Thanks.
I think that you should try different solution: http://aws.amazon.com/simpledb/
It appears that CakePHP is a MVC framework that's very similar to django, which is included in app engine for python. I'm not sure why you would want to store your data in google app engine, unless you're dealing with an extremely large amount of data, in which case you're likely comfortable enough working in python to just make the app work entirely on GAE.
See the official docs for more info:
http://code.google.com/appengine/docs/python/overview.html
http://code.google.com/appengine/articles/django.html
What you can do is run your CakePHP app on a standard LAMP web host and access the GAE Data Store through a REST or RPC web service. This isn't such a bad idea if you already have a CakePHP front-end that deals with RPCs in the backend, but if your Cake app stores all it's Models in MySQL it could take considerable effort to adapt it.CakePHP Models abstract their storage method using the DataSource class. You might be able to find a DataSource class that uses REST or RPC. However, if you don't have a very considerable investment in CakePHP Controllers and Templates I would suggest simply building your app entirely in GAE
You can not run PHP on GAE. If you run PHP somewhere, it is a bad architecture to go over the internet for your data. It will be slooooow and a nightmare to develop in.
You should store your data where you run your php, unless you must have a distributed, globally scaling architecture, which afaiu not the case.
There's a detailed tutorial on getting CakePHP up using the PHP runtime that Google recently announced. http://aymanrb.blogspot.com/2013/05/cakephp-deployment-on-google-app-engine.html