I would like to disable the cache for a self-developed Cake plugin. Is this possible and if so, how would I do this? The reason why is related to an earlier question of mine, where duplicate controller names break parts of my application which were working fine in 1.3.
I know one can disable the Cache by setting the following option in Core.php:
Configure::write('Cache.disable', true);
I thought it would be possible to do the same in PluginAppController.php in the beforeFilter or beforeRender method, but that doesn't seem to be working.
Does anybody know if it's possible to do from the PluginAppController or if there are any other options? Disabling the entire cache is very undesirable as it slows down the rest of the application considerably.
This sounds like poor application architecture. You shouldn't have to disable the cache -- which sounds like it is a bandaid for a larger problem. Why don't you simply rename one of the controllers or add some sort of pseudo namespace naming convention in your app to prevent the issue?
Related
I Created an Extension by using the Extension Builder, created a model, checked all standard actions and aggregated it to root. I installed the extension. I also selected a storage place. I included the static template, created a new page and put the frontend-plugin in and So as far as I know very standard.
And when I started testing, it usually doesn't update old values if i create edit or delete them. Then I check the database, there is everything just fine and as i expect things to be.
What always helps is clearing the frontend Cache and reload.
So how can I tell TYPO3 to not Cache this?
I am using TYPO3 6.2.
config.no_cache disables all caches, which makes your site really slow.
It's better to mark the controller actions as uncached when registering them in ext_localconf.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.Extname',
'Faq',
array('Faq' => 'index,detail'),//available
array('Faq' => 'index')//uncached
);
config.no_cache
For all caches
Is there any way to auto-generate Swagger documentation (or similar) for a Nancy service?
I found Nancy.Swagger, but there's no information on how to use it and the demo application doesn't seem to demonstrate generating documentation (if it does, it's not obvious).
Any help would be appreciated. Thanks!
In my current project I've been looking a lot into this problem. I used both nancy.swagger and nancy.swagger.attributes.
I quickly discarded Nancy.swagger, because for me personally it doesn't sound right that you have to create a pure documentation class for each nancy module. The attributes solution was a bit "cleaner" - at least codebase and documentation were in one place. But very fast this became unmaintainable. Module code is unreadable because of many attributes. Nothing is generated automatically: you have to put path, all parameters, even http method as an attribute. This is a huge effort duplication. Problems came very fast, a few examples:
I changed POST to PUT in Nancy and forgot to update [Method] attribute.
I added a parameter but not the attribute for it.
I changed parameter from path to query and didn't update the attribute.
It's too easy to forget to update the attributes (let alone documentation module solution), which leads to discrepancies between your documentation and actual code base. Our UI team is in another country and they had some trouble using the APIs because docu just wasn't up-to-date.
My solution? Don't mix code and documentation. Generating docu from code (like Swashbuckle does) IS ok, but actually writing docu in code and try to dublicate the code in docu is NOT. It's not better than writing it in a Word document for your clients.
If you want Swagger docu, just do it the Swagger way.
- Spend some time with Swagger.Editor and really author your API in
YAML. It looks all-text and hard, but once you get used to it, it's
not.
- Spend some time with Swagger.Codegen and adapt it (it already does a fair job for generating Nancy server code and with a few
adjustments to moustache templates it was just what I needed).
- Automate your process: write a couple of batches to generate your modules and models from yaml and copy them to your repository.
Benefits? Quite a few:
-
Your YAML definition is now the single truth of your REST contract.
If somewhere something is defferent, it's wrong.
Nancy server code is auto-generated
Client code-bases are auto-generated (in our case it's android, ios and angular)
So whenever I change something in REST contract, all codebases are regenerated and added to projects in one batch. I just have to tell the teams something was updated. They don't have to look through some documents and search for it. They just have their code regenerated and probably see some compile errors, in case of breaking changes.
Do I still use nancy.swagger(.annotations)?
Yes, I do use it in another project, which has just one endpoint with a couple of methods. They don't change often. It's not worth the effort to set up everything, I have my swagger docu fast up and running. But if your project is big, API is changing, and you have multiple code-bases depending on your API, my advice is to invest some time into a real swagger setup.
I am quoting the author answer here from https://github.com/khellang/Nancy.Swagger/issues/59
The installation should be really simple, just pull down the NuGet package, add metadata modules to describe your routes, and hit /api-docs. That should get you the JSON. If you want to add swagger-ui as well, you have to add that manually right now.
No. Not in an automated. https://github.com/yahehe/Nancy.Swagger needs lots of manually created metadata.
There is a nice article here: http://www.c-sharpcorner.com/article/generating-api-document-in-nancy-using-swagger/
Looks like you still have to add swagger-ui separately.
What's the best way to handle the scaffold when it comes to the deployment stage?
Leave it there? But then what's the best way to protect the access of it?
Remove it? But then I need another system to access all the data, right?
How do people usually handle the scaffold in CakePHP which is very useful in the building process?
Most people would not use scaffold anymore when getting close to deployment.
That is where "bake" comes into play.
You usually only scaffold while still changing the database structure heavily.
As soon as it gets stable you use custom bake templates to bake your views to real files.
I actually never use scaffolding as bake has way more advantages (such as full customization of the template output.
And rebaking is not that big of a deal. It is pretty fast to achieve.
Hi I'm using and Custom ServiceHostFactory, and when I want to update service reference it would'nt work because I assume it needs to setup my servicehostfactory and it will crash.
I have looked for other approaches to not use the generation, but I havent found any good replacements.
Are there anyway to go around this, to not remove the servicehostfactory from the svc files everytime and then put them back there after service reference updates :S.
We use the non generation method described in this dnrtv screencast.
It has worked very well for us. Prevoiously we wasted alot of time due to references not updating or developers forgetting to update a reference before they checked in code.
I rechecked the namespace path and it were wrong in the svc file.
I'm running into a problem with GroupsController::build_acl()- http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
It's taken me a while to track down the bug and now I've found it I'm not sure how to work around it.
Symptoms:
Not all methods for NodesController (defined by me) are returned.
Probable reason:
build_acl() imports a 3rd party plugin that also has a NodesController and a subsequent App::import() doesn't overwrite it.
I'm about to try two runs of the build, one with the plugin code commented out, but a more durable solution would be preferred!
I need a way to either drop an imported controller or force a re-import while remaining in scope.
you can not do what you want to do, think about straight php for a while. once you have used include('some/file.php'); how do you un-import it? you cant.
now the reason why you cant overwrite it is once again down to php. what happens if you run
<?php
include('some/file.php');
include('some/file.php');
?>
you will get errors about the class being defined already.
Cake is stopping this from happening, so the only (and correct way) is to not have 2 controllers with the same name. you can name them what ever you like and use the router to map to nice urls.
Turns out the plugin was redundant and not called anywhere in the application and would have broken it if it was as a class redefinition error would have ensued. After removal of the files everything worked okay.