Laravel store views cache to Redis - caching

I'm using Laravel 5 with CACHE_DRIVER redis.
I found that there are still Views cache files under /storage/framework/views/.
Is it possible to store Views cache in redis? I thought that it will speed up the website.
Thanks!

Laravel 5 doesn't support this. config/view.php is rather stubby and makes no mention of drivers, whereas config/session.php and config/cache.php both have keys that make use of CACHE_DRIVER.
You can store the view cache files in a custom location on the filesystem, but other than that, at time of writing, there's not much else you can do with the views configuration.

Related

Laravel 5.5: Entrust This cache store does not support tagging?

I am using Entrust (zizaco/entrust": "5.2.x-dev) for user roles and permissions, everything was working using CACHE_DRIVER=array.
But I have another requirement to lock user on 5 failed login attempts to use that feature I must have to change cache driver to CACHE_DRIVER=file and Entrust does not works on file driver, because file does not support tags.
Also I don't have choice to use other cache drivers memcached, apc, redis .. etc
is there any way to achieve this?
Thanks,
Kaleem

Use same database for 2 Laravel Apps

I am making a web app on Laravel 5.3 which is frontend app. I am managing data from a Backend App. I have already made models and migrations in the frontend app and not in the backend app. So how should I use same database, models and migrations for both. Please help.
You can just create the models in the backend app and they will still work.
If you are using Artisan:
php artisan make:model ModelName
Migration files can be a little more tricky, I would suggest just managing all of this through your frontend app for consistency and then creating the models you need in the backend app.
You didn't mention if your backend app is also using Laravel.
Either way, I think your best approach would be to structure the backend app as an API. Then it would contain the database migrations and models. The back end would be the one to connect directly with the database. The front end would then fetch the data from the back end API and display them. The front end app could then have its own models too (but not database models).
There are arguments to support both using an API on the front-end app to access the backend or just recreating the models on each system. I'm supporting multiple sites which access the same data. It soon became apparent that the best way was to create an API on the backend to service them all. Also worked for other shared resources i.e. images.
There is a slight penalty in the load times but is so small it isnt worth noting. It also helped when using other platforms i.e. ioS, android and Ajax.
You can rename the migrations table in your bootstrap/app.php like this:
$app->configure('database');
$app->config->set('database.migrations', 'backend_migrations');
That way you will get two migration tables, one for the frontend, and one for the backend all in the same database.

Automatic Log In/Authentication Laravel from Other Laravel

I have two Laravel applications that use the same database and, therefore, have the same users and passwords.
Let's say the applications are called A and B.
If a user logs into A, what can I do so that they're automatically logged into B? So if they log into A, then when they go to B, they will not have to type in their login information again.
Both applications are on the same domain, but B is a subdomain and is not part of the same project as A.
Thank you in advance!
When you say Both applications are on the same domain, but B is a subdomain and is not part of the same project as A. can i safely assume that they are two separate installations of Laravel, but they share the same database? I that's the case, you could try this:
Switch the session driver to database in your .env file to "database", for reference you should look at the comments in config/session.php, near the 'driver' => env('SESSION_DRIVER', 'file'), option. Be sure to manage the tables accordingly (see https://laravel.com/docs/5.5/session#driver-prerequisites)
In your .env file, specify this row: SESSION_DOMAIN=.domain.ext (notice the dot near the equal sign).
Alternatively, if even the databases are separate you could try the same config as above using the cookie driver instead fo the database. let me know if this helped.
edit: more a suggestion than an answer, laravel is capable of handling multiple websites/domains natively (example: Route::domain('sub.domain.ext'). Pratically speaking, you organize the routes this way in routes/web.php. With a wise database management (and queries) you can easily mantain 2 separate websites within 1 Laravel application. This assuming you have control over your webserver, of course. If that's the case, i would suggest a refractoring. It's really worth the effort.

how to use laravel illuminate in a custom project

I have a static site with a lot of pages. Now I got a new requirement. Client need a Client Area, I am thinking to use laravel Database Eloquent, Session, Form/html, Session and want to use them as alias like use in laravel/lumen. The problem is that I want static pages same as it is with .html extension, is there any solution? I want some packages with aliases to speed up.
I spent a complete day on Configuring Input and Eloquent but I wasn't able to setup to other packages. But I don't know how to set aliases and service providers. Any idea?
Specific:
I need Laravel Some packages
Session,
FileSystem
Mail
Input
Database
Html/Form,
Validation
I don't need others packages and need aliases same as laravel used in (config/app)
yes you can use laravel components outside laravel project please read the article : http://www.richardbagshaw.co.uk/using-illuminate-components/

How to store data in cache in symfony2

I have a configuration-table(id,name,value), containing some configuration variables for my symfony application such as email_expiration_duration. I want to write a service to read these configuration varibales from symfony application.
I want cache the data in app/cache folder.
That means I will read the data from database only if the data is not in cache.
I will clear the cached data whenever the configuration value changes.
How can I do it in symfony2?
If you want to store this information in a file you manually create in the app/cache folder, you may use the following solution: https://stackoverflow.com/a/13410635/1443490
If you don't want/need to care about what folder is used inside the app/cache folder and your project already uses Doctrine, you can follow this solution: https://stackoverflow.com/a/8900283/1443490

Resources