cakephp-3.0

CakePHP 3.0.8 translate behavior and data validation (requirePresence, notEmpty)

扶醉桌前 提交于 2019-12-01 13:23:04
My problem is simple, yet I can't figure out how to solve it. My website is multilanguage. I want the user to be able to add an article in multiple language if he wants, while requiring the inputs of his language (depending on his locale). Problem is, with CakePHP's conventions about translation, all the inputs must end with the field's name, no matter what language. So all the fields has the same rule for the same field. I can't make one "name" required while another in another language not required. For example, the default language's input would be: <input type="text" name="name" required=

Cakephp: How to use migration to insert records

半世苍凉 提交于 2019-12-01 10:42:52
I'm using CakePHP v3.x and I'm trying to figure out how to insert some records via the migrations tool. The documentation only lists methods for modifying the schema. Will I need to insert records manually with raw SQL? drmonkeyninja CakePHP 3's Migration plugin is a Phinx wrapper plugin, so adding records can be done using the up() method:- public function up() { // Save records to the newly created schema } public function down() { // Remove records } For example, you could add a new user using TableRegistry on up :- public function up() { // Save records to the newly created schema

How to use hybridauth plugin with CakePHP 3.x?

余生颓废 提交于 2019-12-01 10:25:03
问题 I use CakePHP 3.x to create a page can make a social sign in. I found HybridAuth plugin can do that. But, I can't understand about configuration and flow. Who is used to on this plugin? Please help me. 回答1: First of all, I must thank my friend for helping me solve this mystery in cakephp 3. I'm providing the complete options how to use the plugin in cakephp 3 may this give a solution and explore more improvements in that plugin. Step 1: Run in composer php composer.phar require hybridauth

Cakephp: How to use migration to insert records

喜你入骨 提交于 2019-12-01 07:36:37
问题 I'm using CakePHP v3.x and I'm trying to figure out how to insert some records via the migrations tool. The documentation only lists methods for modifying the schema. Will I need to insert records manually with raw SQL? 回答1: CakePHP 3's Migration plugin is a Phinx wrapper plugin, so adding records can be done using the up() method:- public function up() { // Save records to the newly created schema } public function down() { // Remove records } For example, you could add a new user using

$this->set('title', 'Title Name'); not working in CakePHP 3.x

半城伤御伤魂 提交于 2019-12-01 03:29:32
Basically in default.ctp I have this for my title: <title> <?= $this->fetch('title') ?> </title> And inside of the controller I have this line: $this->set('title', 'Test-Title'); But it does nothing, it still displays controllers name(Jobs, controllers full name os JobsController.ctp) But if I put this inside of my view file: $this->assign('title', 'Test-Title'); It changes the title. So what is wrong with $this->set('title', $title) ? You can just set() the variable in your controller: // View or Controller $this->set('title', 'Test-title'); Then use it as a standard variable is in your

installing cakephp 3 manually, without composer

穿精又带淫゛_ 提交于 2019-12-01 02:15:53
I need to install CakePHP 3 in an old-fashioned upload-unzip-run way. The archive I've downloaded from cakephp/cakephp/tags does not contain the default folders like webroot , Model etc., which means it's not complete. The official documentation does not cover this. Here's a relevant Github issue I found, but the person ends up still using Composer. There's also cakephp/app and it seems to include those missing files, but it's not mentioned in cakephp/cakephp 's composer.json, and even if I download it I've no idea how to merge the packages. Please help Packaged app ( cakephp/app ) releases

Cakephp 3 routing with language parameter

喜欢而已 提交于 2019-12-01 01:31:30
问题 I'm trying to convert cakephp 2.x to 3.x. I was using Router::connect() rules, but I try to convert them to scope version. Regarding to myold routing rule, in config/routes.php I added this. Router::defaultRouteClass('Route'); Router::scope('/', function ($routes) { $routes->connect('/:language/:controller/:action/*', ['language' => 'ar|de|en|fr']); $routes->connect('/:language/:controller', ['action' => 'index', 'language' => 'ar|de|en|fr']); $routes->connect('/:language', ['controller' =>

Cakephp 3 NOT IN query

巧了我就是萌 提交于 2019-11-30 15:24:19
问题 I think this is a common pattern, but I can't find the elegant CakePHP way of doing it. The idea is to remove the values from a list which have already been chosen. To use an example from the Cake book: table Students (id int, name varchar) table Courses (id int, name varchar) table CoursesMemberships (id int, student_id int, course_id int, days_attended int, grade varchar) All I want to do is create a query which returns the courses that a given student has not yet signed up for, most

How to increase cakephp Auth component session expire time

↘锁芯ラ 提交于 2019-11-30 15:02:01
问题 I am using Auth component to check user is logged in. Here is my AppController's initialize function public function initialize() { parent::initialize(); $this->loadComponent('Flash'); $this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'fields' => [ 'username' => 'username', 'password' => 'password' ], 'passwordHasher' => [ 'className' => 'Md5',//My own password hasher ] ] ], 'loginAction' => [ 'controller' => 'Dashboard', 'action' => 'login' ] ]); } Its working fine.But if I stay

Cakephp 3 NOT IN query

这一生的挚爱 提交于 2019-11-30 13:54:20
I think this is a common pattern, but I can't find the elegant CakePHP way of doing it. The idea is to remove the values from a list which have already been chosen. To use an example from the Cake book: table Students (id int, name varchar) table Courses (id int, name varchar) table CoursesMemberships (id int, student_id int, course_id int, days_attended int, grade varchar) All I want to do is create a query which returns the courses that a given student has not yet signed up for, most probably to populate a select dropdown. If I weren't using Cake, I'd do something like select * from Courses