cakephp-3.0

Cakephp 3.0 Login returns false every time

拟墨画扇 提交于 2019-12-24 03:35:01
问题 I am trying to log in a user on my Cakephp 3.0 site. My table has a 'username' and 'password' field, named as is. I can add a user and my password is successfully getting hashed and stored in my table. Despite this, I am unable to log in even once. My AppController initialize() method: $this->loadComponent('Auth',['loginAction' => [ 'controller' => 'ShopOwners', 'action' => 'login' ],'authenticate' => [ 'Form' => [ 'fields' => [ 'username' => 'username', 'password' => 'password', ],

CakePHP 3.x - fixtures import does not load data

守給你的承諾、 提交于 2019-12-24 03:27:26
问题 I am trying to import fixtures in my CakePHP 3.x plugin. When I launch the tests, I always get the error : UserManager\Test\TestCase\Controller\UsersControllerTest::testProfile exception 'Cake\Datasource\Exception\RecordNotFoundException' with message 'Record not found in table "users" Here is UsersFixture.php : namespace UserManager\Test\Fixture; use Cake\TestSuite\Fixture\TestFixture; class UsersFixture extends TestFixture { public $import = ['table' => 'users']; } My test fails because it

Cakephp 3 - MissingDatasourceConfigException when running phpunit test

前提是你 提交于 2019-12-24 03:24:02
问题 I am trying to run some unit tests in CakePHP 3 with PHPUnit 4.7.3, but I`m getting the following error: PHPUnit 4.7.3 by Sebastian Bergmann and contributors. There was 1 error: 1) App\Test\TestCase\Model\Table\MoviesTableTest::testFindMoviesByGenre Cake\Datasource\Exception\MissingDatasourceConfigException: The datasource configuration "default" was not found. C:\xampp\htdocs\movie-pal\vendor\cakephp\cakephp\src\Datasource\ConnectionManager.php:188 C:\xampp\htdocs\movie-pal\vendor\cakephp

CakePHP 3 losing Auth Session

谁说胖子不能爱 提交于 2019-12-24 03:11:16
问题 I am using Auth Session in CakePHP. 'Session' => [ 'timeout' => 0, 'defaults' => 'php', 'ini' => [ 'session.cookie_secure' => false, 'session.cookie_lifetime' => 0 ] ], Already configured this in tha app.php but still getting logged out after few minutes. Although Session persists when closing Browser. So i think its just a time related problem. 回答1: I was having requirement to increase session timeout in cakphp 2.5 the following code worked for me in 2.5 you can give this a try //FILE:

CakePHP 3 - How to write COALESCE(…) in query builder?

拟墨画扇 提交于 2019-12-24 00:57:20
问题 How do I write this kind of COALESCE() statement in the query builder? SQL SELECT COALESCE(n.value, p.value) AS value FROM nodes n LEFT JOIN parents p ON p.id = n.parent_id PHP I can retrieve both the child and parent values and then go through the result set and just use the parent one if the child one is empty, but if there is a more elegant way to build it into the query itself, I would prefer that. $child = $this->Nodes->find() ->select(['id', 'value']) ->where(['Nodes.id' => $id]) -

How to call PDOStatement::nextRowset() in Cakephp 3

蓝咒 提交于 2019-12-23 23:35:30
问题 I have created a procedure in which i there are two select statements are running. $stmt = $this->_connection->execute("CALL myFunction(:user_id)", [ 'user_id' => $userId ]); But when i am trying to call the nextRowset() like this $stmt->nextRowset(); Its giving me error Call to undefined method Cake\Database\Log\LoggingStatement::nextRowset() So, My question is how can i call the nextRowset() in Cakephp 3 回答1: Given that all core statement classes do extend \Cake\Database\Statement

How to alter view blocks content from controller in CakePHP 3?

萝らか妹 提交于 2019-12-23 21:25:58
问题 Inside Layouts/default.ctp you will see something like this at line 39: <div class="header-title"> <span><?= $this->fetch('title') ?></span> </div> fetch suggests that it is a view block. I couldn't find this view block anywhere. Currently it just displays the capitalized plural form of controller. Meaning to say if you are at /users/add , the fetch('title'); gives you 'Users' I want to change it. So I tried the following: $this->set('title', 'Login'); in the /users/login controller action.

Blank page after installing CakePHP 3

余生长醉 提交于 2019-12-23 21:15:32
问题 I have copied a new installation of CakePHP 3 to a webhotel. On my local installation it runs without problems and shows the standard startup page, but on the webhotel I get a blank page. If I place a test.php in /webroot it displays without errors. If I in webroot/index.php include an echo 'Show this line' just before the line with require dirname( DIR ) . '/config/bootstrap.php'; it is displayed. If I move the echo line below the require line it will not display. So the error must be with

CakePHP 3 and form validation errors

醉酒当歌 提交于 2019-12-23 16:08:32
问题 I use cakePHP 3 and I have a sign in form with Form->input(). If on purpose I make an error, this error doesn't whow up under the Form field. It doesn't appear anywhere. My code is like this: $newUser = $this->Users->newEntity($this->request->data()); if (!$this->Users->save($newUser)) { debug($newUser->errors()); $this->Flash->error('Error'); return; } Debug show the errors, but shouldn't they appear under each form element automatically? 回答1: ok I found the error. I wasn't passing in Form-

CakePHP 3 Composer Installation Error

淺唱寂寞╮ 提交于 2019-12-23 12:38:56
问题 I am trying to create a project as shown in the official Bookmarker Tutorial using the following command: composer create-project --prefer-dist cakephp/app bookmarker Then I see the following errors: [RuntimeException] Could not load package cakephp/migrations in http://packagist.org: [UnexpectedValueException] Could not parse version constraint >=0.4.2 <1.0: Invalid version string "0.4.2 <1.0" [UnexpectedValueException] Could not parse version constraint >=0.4.2 <1.0: Invalid version string