cakephp-3.0

CakePHP command line doesn't work when xdebug loaded

六月ゝ 毕业季﹏ 提交于 2019-12-01 20:25:59
问题 I'm trying to use xdebug against PHP 7.1.6 to troubleshoot a failing unit test in my CakePHP v3.3.6 project. I've set up xdebug using the following settings: [xdebug] xdebug.remote_enable = on xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.remote_autostart = 1 xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir = "c:/wamp/tmp" xdebug.show_local_vars=0 xdebug.max_nesting_level=256 PHP

CakePHP command line doesn't work when xdebug loaded

跟風遠走 提交于 2019-12-01 20:05:12
I'm trying to use xdebug against PHP 7.1.6 to troubleshoot a failing unit test in my CakePHP v3.3.6 project. I've set up xdebug using the following settings: [xdebug] xdebug.remote_enable = on xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.remote_autostart = 1 xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir = "c:/wamp/tmp" xdebug.show_local_vars=0 xdebug.max_nesting_level=256 PHP now connects to my xdebug client (VisualStudio Code) but as soon as I run phpunit ./vendor/phpunit

How to select a specific field additionally to a tables default fields?

[亡魂溺海] 提交于 2019-12-01 19:51:45
I an looking to use a JOIN to select data from a table and a view in CakePHP like so : $this->Annonces->find('all') ->where($arrFiltres) ->order($arrOrder) ->join([ 'table' => 'annonces_suivis', 'alias' => 'AnnoncesSuivis', 'conditions' => [...], ]); And would like to be able to select all the fields from the first table and som of the jointed table like so : ->select(['Annonces.*', 'AnnoncesSuivis.id']); But this creates a faulty SQL query. .* isn't supported by the ORM Query, it will convert this to Annonces.* AS Annonces__* which is invalid SQL. It would work with the lower level Database

cakephp 3 original data in afterSave

拜拜、爱过 提交于 2019-12-01 19:43:53
Is there any way to access original data in afterSave? I would like to log the changes on important data. With $entity->isNew() I could check if it was an insert or an update, but how can I get what changed? You can access the original values via Entity::getOriginal() or Entity::extractOriginal() . If you want to get all changed fields, combine the latter one with Entity::visibleProperties() , something like: debug($entity->extractOriginal($entity->visibleProperties())); This should return the original values of all changed fields. See also http://api.cakephp.org/3.0/class-Cake.Datasource

Input wrapper div class in CakePHP 3.0.0

荒凉一梦 提交于 2019-12-01 17:13:29
How can I change input wrapper div class in CakePHP 3.0.0.? My code is: <?= $this->Form->input('mobile',['div'=>['class'=>'col-md-4'],'class'=>'form-control','label'=>false]) ?> and it returns: <div class="input text"> <input type="text" name="mobile" div="col-md-4" class="form-control" id="mobile"> </div> I want output like: <div class="col-md-4"> <input type="text" name="mobile" class="form-control" id="mobile"> </div> For CakePHP 3.0 versions ... ... there is no way to just pass on attributes to a template. You'd have to redefine the appropriate form helper templates. You can either change

Loading javascript files from the vendors in CakePHP 3

大城市里の小女人 提交于 2019-12-01 16:56:47
问题 My problem is how to load .js files from the vendors folder in CakePHP 3.0. I have included twitter bootstrap via composer. The .js file is located in /vendor/twbs/bootstrap-sass/assets/javascripts/ folder. I don't want to move it to webroot because then I'll break the auto-update functionality provided from composer. Any good suggestions? I don't want to duplicate files and loose the composer benefits... 回答1: I've found a solution! If I'm using composer why not to use it for this too, right?

Using limit() on contained model

我的未来我决定 提交于 2019-12-01 16:21:28
The Code Say I have two models, named Product and Image , which are linked by Product hasMany Image and Image belongsTo Product . Now, say I want to fetch all products with the first image each. I would use this code: $this->Products->find('all') ->contain([ 'Images' => function($q) { return $q ->order('created ASC') ->limit(1); } ]); Looks about right, right? Except now only one of the products contains an image, although actually each product contains at least one image (if queried without the limit). The resulting Queries The problem seems to be with the limit, since this produces the

Can I set the default order on the Table class on cakephp3

蹲街弑〆低调 提交于 2019-12-01 16:14:18
问题 In CakePHP 2.x there was a property $order in Models. So I used this property to order my data globally. So for example assuming that I need to show a select box with countries on a view in my Country model used to add the line: $order = 'Country.country DESC'; and then when I fetched the countries from any controller the data where ordered by the country name and not by the id or any other field. This was very helpful specially for the select boxes. On CakePHP 3.x I can't seem to find any

Input wrapper div class in CakePHP 3.0.0

橙三吉。 提交于 2019-12-01 15:57:46
问题 How can I change input wrapper div class in CakePHP 3.0.0.? My code is: <?= $this->Form->input('mobile',['div'=>['class'=>'col-md-4'],'class'=>'form-control','label'=>false]) ?> and it returns: <div class="input text"> <input type="text" name="mobile" div="col-md-4" class="form-control" id="mobile"> </div> I want output like: <div class="col-md-4"> <input type="text" name="mobile" class="form-control" id="mobile"> </div> 回答1: For CakePHP 3.0 versions ... ... there is no way to just pass on

Using limit() on contained model

…衆ロ難τιáo~ 提交于 2019-12-01 15:50:28
问题 The Code Say I have two models, named Product and Image , which are linked by Product hasMany Image and Image belongsTo Product . Now, say I want to fetch all products with the first image each. I would use this code: $this->Products->find('all') ->contain([ 'Images' => function($q) { return $q ->order('created ASC') ->limit(1); } ]); Looks about right, right? Except now only one of the products contains an image, although actually each product contains at least one image (if queried without