cakephp translationos po files in plugins - cakephp

simple question but I cannot find the answer in the CakePHP 3 documentation. I have a global translation for each language, located in src/Locale/it_IT/default.po and I have also many plugins (for example) /plugins/myplugin/src/Locale/myplugin.po with translations as well. I thought that in case of duplicates (the same sentence in the plugin po and the default.po), CakePHP will take the plugin one, but I am not sure, if that is correct? Sometimes I updated the translation but CakePhp did not take the updates, I am not sure if it is the cache, but I always remove the cache after adding a new sentence to the po file like this " rm -fr /tmp/cache/myplugin/".
Thanks

Solved! I just added a .ebextensions (for Elastic Beanstalk AWS) to remove and change the permissions of the cache folder, that's it!.

Related

How to build an Alexa skill with multiple developers?

I'm struggling to handle the pipeline building an Alexa skill across several developers and existing docs just aren't cutting it.
We have four developers and when we check our code into our git repo, checkout new branches and so forth, we're continually overwriting our .ask/config and skill.json files.
How do we set this up to avoid overwriting? Ideally we're all building towards the same Alexa skill but we'd each like to test in our own instance -- separate skills and separate lambda functions.
As soon as I grab another developers branch, I lose my necessary config and skill files.
My gitignore has these files ignored, but since they're checked in they're continually being tracked.
How do I handle multiple developers?
I see several problems here.
First of all - clean up your repo: make sure that all developers have ./ask/* entry added to their .gitignore files and ./ask directory is removed from the origin.
To solve overriding problem - you can create a template-skill.json with placeholders for lambda's ARNs and all the other things different for each developer. Then, before ask deploy just create the valid skill.json file by running some script that replaces placeholders in the template JSON with your data (kept in another gitignored file).
Setup the same in your CI instance with configurations for different environments.

How do I reset hugo's content listing cache?

I accidentally created content with the wrong path using hugo new content/my-page as opposed to hugo new my-page, and now the content (and its folder) keeps reappearing when I delete the content/content folder.
How do I get rid of this post for good? There doesn't appear to be a hugo delete command - so where is this information stored?
I assume you're using hugo serve to test your site?
If so, this is a side-effect of the hugo cache - in order to remain quick, deleted and renamed files will remain in the cache, and can thus be accessed. By restarting the server, the cache is cleared; which is why your problem fixed itself.
This isn't usually a problem, as you can rebuild the site at any time, and clear the cache when doing so.
I think you have a two options:
1 - ignore the files during development, knowing they will not exist in production
2 - restart the server after deleting or renaming files
Either way, knowledge of the problem is part of the solution.

CakePHP memcached configuration in core.php or bootstrap.php

I am trying to figure out where to setup my memcached configuration in CakePHP 2. Both core.php and bootstrap.php have sections to set up any cache such as memcached, but I still haven't figured out which file to use.
Also the CakePHP documentation is not so clear about this in my eyes.
Could anyone point out what part of the memcached configuration goes into which file please.
Really, you can place configuration values anywhere you would like, even in their own files as long as you load them in core.php or bootstrap.php. However, the default 2.0 core.php file states that other cache configurations should be in bootstrap.php as stated here: https://github.com/cakephp/cakephp/blob/master/app/Config/core.php#L349.
FWIW, we load addition configuration files depending on an environment variable (APP_ENV) as well as a location specific one that overrides all others. We call it core-local.php but the name doesn't really matter as long as it's not tracked in your VCS.
Edit:
Here's how we load environment specific configs. This is towards the end of our core.php so that the configs loaded after it are not overwritten.
$env = getenv('APP_ENV');
if (is_readable(dirname(__FILE__) . "/core-{$env}.php")) {
Configure::load("core-{$env}");
}
End Edit
Lastly, the CakePHP docs are really easy to edit and PRs are very welcome. If you think you can clarify the docs just click on the link at the top of the documentation page and edit away. You can then use the GitHub UI to submit the PR. No editor or git binary is necessary.

Share controllers, models and views in multisite CakePHP 2.3 installation

I'm creating a CakePHP 2.3 advanced installation (several apps -websites- that share one same lib folder where all of cake's core files are located). This works without any problems, I just edit the core.php file in the Config folder for each app so it knows where to find cake's files. The file system looks something like:
[root]
[cake-core-files]
[websites]
[website-1]
[app]
[plugins]
[vendors]
[website-2]
...
[website-N]
These different apps are in fact different in some things (they are different websites) but at the same time there's many things that are common to all of them (for example some models, controllers, functions...). What I would like to do, if possible, is to have those apps also share a bunch of controllers, models, etc so I can put them in one place, instead of replicating them now for each app.
I've seen the concept of vendors and plugins in CakePHP (I actually use plugins in those websites, but from the /app/plugins folder), but I'm not sure if that would work in my case, or how I would set that up. I guess the idea would be to have another folder (for example [shared_objects]) at the same level of [cake-core-files] and [websites], but I don't know how I would have to configure cake to do that or how to call those objects from each app.
Any ideas?
EDIT
Based on the comments/responses below I'm trying to do this using the App:build() function in the bootstrap.php, but I can't get it to work. This is what I've done:
Added a new folder where I want to put the stuff to share between all apps:
[root]
[cake-core-files]
[shared-stuff] --> NEW FOLDER
[Model]
[Config]
[websites]
[website-1]
etc...
Placed the model User.php inside the new folder [shared-stuff/Model]
Added this line in the bootstrap:
App::build(array('Model' => array('/path/to/shared-stuff/Model')));
Deleted the model User.php from its original location [website-1/app/Model]
After this steps, it seems to work, the model User.php is loaded correctly from the [shared-stuff] folder (I've tested that printing App::objects('Model');, the User model is listed). However, it actually doesn't work, when I call that model from the UsersController in the login() function, the login doesn't work (although I don't receive any kind of error, even with debug set to 2).
This model uses a database configuration different from the default one (the users table is located in a different database than the default one). I don't know if this matters.
One thing is for sure, if I leave the same exact User.php model in its original location ( [website-1/app/Model]) it all works fine, including the login, so it's a problem with how I try to configure all this sharing stuff, not the model itself.
Any ideas what am I doing wrong?
I think it could be useful to share some controller/model between multiple websites, and do it without a plugin: Using shared controller/model lets you to overwrite it if needed. It should happen simply copying the controller/model in the website's correct folder and the system should use it instead of the shared one!
EDIT: Wonderful, it works, but i think there is a little error in cake's official documentation: All paths should be terminated with a Directory separator! In the cakephp book there aren't trailing slash. Add it to your App::build path and everything will work perfectly!
You can have plugins in the core Plugins/ dir
[root]
[lib]
[Cake]
[Plugins]
[Available]
[To]
[All]
[website-1] // the 'app' dir -> https://github.com/cakephp/cakephp/tree/master/app
[plugins]
[vendors]
[website-2] // you can have many of them named anything, 'app' is just one.
...
[website-N]
This folder specifically will make the plugins available to any app using the cake lib
EG:
Look at this. Copy app to website-1, repeat till website-n.

Missing Controller Error in Cakephp 2.0.4

Apologies if I ask a silly question, I am quite new to CakePhp
I have installed Cakephp 2.0.4 on dev.ayumma.com (Used Git Clone on, Amazon ec2 machine, amazon linux, with mysql php5, etc.)
I have configured apache with mod_rewrite loaded (you can verify here). I am using the cake 2.0 documentation for a development installation.
My paths are absolute you can see that here as I print them on the page.
I am copying code from the cakephp 2.0 documentation.
Code is in the correct folders, case is correct on file names, and I even copied and renamed files according to error message, just in case. Database was created from the code on the tutorial. The routes.php file has required CAKE . 'Config' . DS . 'routes.php';.
I have ruled out file location. Files are in the correct folders
I have ruled out mod_rewrite. Seems to be loaded, not sure how else to test.
I have ruled out absolute paths. The paths show up correctly.
I have ruled out the routes.php file. Last line is correct.
What am I missing? Any help would be appreciated. I am sure its probably something simple, but at this moment it is out of my grasp.
Offending page is here.
The erorr message means that you have not created the required controller for the posts table.
Make sure you have created Controller, Model and Views for posts table. controller file should be named as PostsController.php, model file as Post.php and View files are named as index.ctp, view.ctp etc .

Resources