cakephp | Code has been split into separate repos | Web Framework library
kandi X-RAY | cakephp Summary
kandi X-RAY | cakephp Summary
Code has been split into separate repos
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cakephp
cakephp Key Features
cakephp Examples and Code Snippets
Community Discussions
Trending Discussions on cakephp
QUESTION
ANSWER
Answered 2022-Mar-16 at 17:57Add css class to input label:
php:
QUESTION
ANSWER
Answered 2022-Mar-04 at 11:43Due to the cakephp naming convention, you have that error message.
Solution I:
use url like: http://localhost/app/locate-i-t-a-p-i.json
Solution II: Add in router:
QUESTION
I cannot seem to override TemplateCommand
from my plugin.
Original TemplateCommand
located here: vendor/cakephp/bake/src/Command/TemplateCommand.php
ANSWER
Answered 2022-Feb-13 at 16:16Your namespace is wrong, there is no Bake
folder in the path to your class file. This mismatch will cause checks for the class' existence to fail, and subsequently cause the autoloader to load the file multiple times, resulting in the error that you're seeing, as a class can only be declared once.
QUESTION
I am using CakePHP 2.x and I want to write unit tests.
In the controller there are several places where exists a read from the Configuration file, like:
...ANSWER
Answered 2022-Feb-14 at 16:29No, such a hard coded static call cannot be mocked, at least not in the context of how the application, the framework, and PHP in general work. Technically it's possible to create mocks for static calls using an aliased class, but that would require to set up the alias outside of the test environment, as it needs to happen before the original class is being loaded.
What you can do however is simply write to the config before testing the action, eg
QUESTION
CakePHP Version: 4.2.6
Xampp:
Apache/2.4.51 (Win64) OpenSSL/1.1.1l PHP/8.0.11
Server version: 10.4.21-MariaDB - mariadb.org binary distribution
PHP version: 8.0.11
Introduction
I'm trying to construct a deleteAll query with the order by and limit clauses.
SQL
When the following sql is run in the xampp sql tab window it deletes just one row in the correct order which is what I wanted it to do.
...ANSWER
Answered 2022-Feb-03 at 12:15Check the API docs for Table::deleteAll()
, it's a convenience method for deleting all records that match the given conditions, and it will return the number of affected rows.
For more complex queries you can generally use the query builder, however currently ORDER
and LIMIT
are not supported for UPDATE
and DELETE
queries. The last attempt to implement it in a cross-DBMS fashion was unfortunately abandoned.
Currently you can either use completely raw SQL, or in your specific case for MariaDB/MySQL, you could use the query builder's epilog to append the ORDER
and LIMIT
clauses:
QUESTION
I'm currently attempting a migration from 3.10.2
to 4.0
. I've gone through the guide and I'm now trying to fix issues as they come up.
I'm finding this one rather cryptic.
Argument 1 passed to pluginSplit() must be of the type string, array given, called in C:\path\to\app\vendor\cakephp\cakephp\src\Core\ObjectRegistry.php on line 300
I suspect it's related to loading plugins. I'm not finding any references to my own files in the stack trace:
...ANSWER
Answered 2022-Jan-22 at 16:24The way you define the options for the helper is wrong, it must be defined as the value for an array key, not as a separate array entry, otherwise that array is being passed into the logic that parses the helper name, resulting in the error that you're seeing.
Long story short:
QUESTION
I'm doing some development in CakePHP 4. Still very new to it so this might be straightforward.
I have a table of housing developments that has a simple structure -
...ANSWER
Answered 2021-Nov-30 at 15:27Please read:
https://book.cakephp.org/4/en/orm/query-builder.html#getting-results https://book.cakephp.org/4/en/orm/query-builder.html#window-functions
Or in your template view or Entity virtual field you can use collections max and min function
https://book.cakephp.org/4/en/core-libraries/collections.html#Cake\Collection\Collection::max
QUESTION
I have an application in CakePHP 4 and am having problems saving associated model data. I have read Saving Associated Data in the Cake documentation but it's very unclear how this applies especially in my use-case.
The application has 3 tables which are relevant to this question:
items
sizes
items_sizes_wanted
The application allows users to request items of clothing (items
) and the form to input/save such an item has a dropdown of different sizes (sizes
). Each size has a unique ID. A user can select one or more size when saving an item. The items_sizes_wanted
table is supposed to hold one (or more) rows depending on the sizes the user selected, with the corresponding item ID. For example if they saved sizes 2, 3 and 4 for Item 999 there would be 3 rows in this table:
ANSWER
Answered 2021-Oct-28 at 17:05Disclaimer: I do not know CakePHP well, but I think I either know the solution, or can at least point you in the right direction.
The reason you're only getting the one selected size, instead of multiple, is because the generated input fields are named items_sizes_wanted[size_id]
, however, in order for PHP to parse multiple values into an array, they need to be named items_sizes_wanted[size_id][]
. When the request parameter ends with []
, then PHP will properly parse all request properties into an array.
For example: Here's var_dump($_POST);
of a request containing the POST body of items_sizes_wanted[size_id][]=A&items_sizes_wanted[size_id][]=B&items_sizes_wanted[size_id][]=C
QUESTION
I want to set cookie value in one function and their value use everywhere in cakephp 4 version. Currently , i can use cookie value inside the only one function which i have set their value.
- I can get cookie value in index() function but i can't get cookie value in viewusers() function. Code is here :
use App\Controller\AppController;
use Cake\Http\Cookie\Cookie;
use Cake\Http\Cookie\CookieCollection
use DateTime;
class AdminController extends AppController {
...ANSWER
Answered 2021-Oct-04 at 05:35Try this:
QUESTION
I'm not an expert of Collections concept in CakePhp 4, and I don't know how to pass a variable in Collection::map()
...ANSWER
Answered 2021-Sep-26 at 14:34The use
keyword helps with this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cakephp
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page