Logs for #cakephp

Page 9 of 36,478, showing 100 records out of 3,647,755 total, starting on record 801, ending on 900

# At Username Text
# Jan 20th, 15:31 neon1024 That controls the conversion
# Jan 20th, 15:29 neon1024 I’d look at `_hydrate()` method in Query
# Jan 20th, 15:24 val @ndm, @admad what method should be overriden if I want that `Cake\ORM\Query->first()` would return a special object instead of `null` in case when no record is found in 3.x? I have difficulties in locating places where the entities are actually constructed.
# Jan 20th, 14:23 ricksaccous @admad nice if that's the case that might make things loads easier, i'm going to try that
# Jan 20th, 14:07 martin https://www.munderwood.ca/index.php/2017/02/28/responding-to-http-options-requests-in-cakephp/ this way
# Jan 20th, 14:07 martin fixed the options method with a middleware :)
# Jan 20th, 13:36 admad you can instead just use `$file->getStream()->getMetadata()['uri']` to get the file path to pass to flysystem
# Jan 20th, 13:35 ndm or reattach it
# Jan 20th, 13:35 admad so be sure you don't need to use the stream instance afterwards :)
# Jan 20th, 13:34 admad "After the stream has been detached, the stream is in an unusable state."
# Jan 20th, 13:33 ndm np
# Jan 20th, 13:33 ricksaccous Thanks
# Jan 20th, 13:32 ndm so `$upload->getStream()->detach()`
# Jan 20th, 13:32 ricksaccous Alright awesome I'll try detach
# Jan 20th, 13:32 ndm detach() will give you the resource ig neccesary
# Jan 20th, 13:32 mr.kusmadi @ricksaccous Use this $datas = $this->request->getData(); $datas['logo']->getClientMediaType(); //to check type of file $datas['logo']->getClientFilename(); //to get filename
# Jan 20th, 13:32 admad it's sad the flysystem doesn't directly support psr7 stream objects
# Jan 20th, 13:31 ricksaccous Or whatever that library is
# Jan 20th, 13:31 ricksaccous To feed it to FlySystem Adapters lol
# Jan 20th, 13:31 ndm Why would you want to do that?
# Jan 20th, 13:30 ricksaccous So how do I turn it into a resource after calling getStream()?
# Jan 20th, 13:29 ndm And a class that calls itself stream isn't a resource, but it usually holds a resource
# Jan 20th, 13:28 ndm @ricksaccous All streams are resources, but not all resources are streams. To obtain the stream of an uploaded file object, use its `getStream()` method.
# Jan 20th, 13:26 HumanG33k and the wrong json
# Jan 20th, 13:26 HumanG33k @chalgren ok thx the only thing missing at the end was the application.php stuff
# Jan 20th, 13:25 martin Hi, I'm currently rebuild a project (with CRUD plugin) to REST backend, but I see that the OPTIONS http method always returns 404. what is a good way to fix this? the frontent does a OPTIONS method before delete/put to check the CORS
# Jan 20th, 13:25 ricksaccous How do you translate that object you get into a resource
# Jan 20th, 13:24 ricksaccous In CakePHP4 it seems that for file uploads you get that object but the file property is private that I'm used to using
# Jan 20th, 13:23 ricksaccous I'm having trouble wrapping my head around the difference between streams and resources and consequently getting a resource from a stream
# Jan 20th, 13:20 slackebot $authenticationService->loadAuthenticator('Authentication.Form', [ 'resolver' => [ 'className' => 'Authentication.AdminOrm', 'userModels' => ['Admin','Users','Students'], ], 'fields' => [ 'username' => 'username', 'password' => 'password', ], 'loginUrl' => ['/simsiswa/admin','/simsiswa/staff','/simsiswa/user'], ]);``` #6.
# Jan 20th, 13:20 slackebot Alhamdulillah successfully
# Jan 20th, 13:20 mr.kusmadi Hai @ricksaccous @conehead I am glad, your suggestion was successful *Hope it is useful for others* *How do you create multiple logins with multiple tables on cakephp 4.x?* #1. I have followed the guidelines at https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html #2. Open app/vendor/cakephp/authentication/src/Identifier/Resolver/OrmResolver.php #3. Modify this code ``` protected $_defaultConfig = [
# Jan 20th, 13:20 slackebot 'userModels' => [], 'finder' => 'all', ];``` #4. Modify this code ``` public function find(array $conditions, $type = self::TYPE_AND) { foreach($this->_config['userModels'] as $configUserModels){ $table = $this->getTableLocator()->get($configUserModels); $query = $table->query(); $finders = (array)$this->_config['finder']; foreach ($finders as $finder => $options) {
# Jan 20th, 13:20 slackebot $where[$field] = $value; } if($query->where([$type => $where])->first() != null){ return $query->where([$type => $where])->first(); } } }``` #5. Open src/Application.php #6. Modify this code ``` $authenticationService->loadIdentifier('Authentication.Password', [ 'resolver' => [ 'className' => 'Authentication.AdminOrm',
# Jan 20th, 13:20 slackebot if (is_string($options)) { $query->find($options); } else { $query->find($finder, $options); } } $where = []; foreach ($conditions as $field => $value) { $field = $table->aliasField($field); if (is_array($value)) { $field = $field . ' IN'; }
# Jan 20th, 13:20 slackebot 'userModels' => ['Admin','Users','Students'], ], 'fields' => [ 'username' => 'username', 'password' => 'password', ], ]); // Load the authenticators, you want session first $authenticationService->loadAuthenticator('Authentication.Session'); // Configure form data check to pick username and password
# Jan 20th, 12:33 barlas So, remove the plugins, install cake 4, and then re-add them if required.
# Jan 20th, 12:32 neon1024 You’ll need to use the cake 4 compatible versions of the plugins, or remove ones which do not yet support cake 4
# Jan 20th, 12:31 barlas Any solutions? :)
# Jan 20th, 12:30 neon1024 Yes, that’s an issue you’ll have.
# Jan 20th, 12:27 barlas Composer isn't letting me upgrade to cake 4, because these require cake3, and not allowing to upgrade these, becausue the next version require cake 4
# Jan 20th, 12:26 barlas I am trying to upgrade my cake 3 app to cake 4, but getting some issues when trying to update the dependencies, like migrations, bake, debug_kit etc
# Jan 20th, 12:25 barlas Hi
# Jan 20th, 11:59 challgren Other than that the controller was the default baked one, the only file changes was the Application.php::middleware() and the json that was being sent
# Jan 20th, 11:52 challgren And then your request data should be {“name”: “England”}
# Jan 20th, 11:51 challgren @humang33k figured it out https://gist.github.com/challgren/b9d8facfe4004ff2d445bbfa167cf6a7
# Jan 20th, 11:50 challgren curl -XPOST -H ‘Accept: application/json’ -H ‘Content-type: application/json’ -d ‘{“name”: “England”}’ ’http://localhost:8080/countries/add'
# Jan 20th, 11:21 challgren The deprecation tells you what wrong
# Jan 20th, 11:18 HumanG33k https://paste.debian.net/1126781/ @challgren with your request
# Jan 20th, 11:07 challgren curl -XPOST -H ‘Accept: application/json’ -H “Content-type: application/json” -d ‘{“country”: {“name”: “England”}}’ ’https://ensd3uvg3k4ui.x.pipedream.net/'
# Jan 20th, 11:05 challgren Data comes across just fine
# Jan 20th, 11:05 challgren https://requestbin.com/r/ensd3uvg3k4ui/1Wem9MrblAFjfL6hA5fudBXXEWC
# Jan 20th, 11:04 challgren curl -XPOST -H ‘Accept: application/json’ -H “Content-type: application/json” -d ‘{ “country”: { “name”: “England” } }’ ’https://ensd3uvg3k4ui.x.pipedream.net/'
# Jan 20th, 11:03 HumanG33k @challgren with the two header there is an exeption
# Jan 20th, 10:59 challgren Plus the json your sending isn’t even properly formatted
# Jan 20th, 10:57 challgren curl -i -H “Accept: application/json” -H “Content-Type: application.json” -X POST -d “{‘country’: {‘name’: ‘England’}}“;
# Jan 20th, 10:56 challgren Ok well you just changed the accepts you need a Content-Type so cake knows you are sending json and not text/plain
# Jan 20th, 10:56 HumanG33k but nothing change @challgren
# Jan 20th, 10:45 HumanG33k of json
# Jan 20th, 10:45 HumanG33k i fix typo
# Jan 20th, 10:43 challgren You should also be sending Content-Type: application/json in your headers
# Jan 20th, 10:36 challgren https://book.cakephp.org/4/en/controllers/middleware.html#body-parser-middleware
# Jan 20th, 10:36 challgren Or you can use the Body Parser Middleware
# Jan 20th, 10:35 challgren https://www.php.net/manual/en/function.json-decode.php has the arguments listed
# Jan 20th, 10:34 challgren If you look at the code it calls the first argument of the input function and then passed the body as argument 1 and the rest of the arguments as 2,3,4, etc
# Jan 20th, 10:32 challgren try $this->request->input(‘json_decode’, true);
# Jan 20th, 10:30 HumanG33k and its look like whatever i test even without option it s look like the $jsonData is null
# Jan 20th, 10:26 HumanG33k ?
# Jan 20th, 10:26 HumanG33k ["as" => 'array']
# Jan 20th, 10:25 HumanG33k @challgren there is no more information than in the book in the source code. so i not really know how to use the "as array" option for input('json_decode')
# Jan 20th, 10:12 HumanG33k ok maybe it can be a good thing to fix it. No doc == less user andand more requests here (i guess)
# Jan 20th, 10:08 challgren Which is why the api docs havent been updated
# Jan 20th, 10:08 challgren Best to use an IDE and “Go to deceleration” I know apigen has issues with PHP 7.2
# Jan 20th, 10:07 neon1024 You can browse the source for the api documentation, as the html is parsed from the souce afaik
# Jan 20th, 10:05 HumanG33k there is no v4 api documentation ?
# Jan 20th, 10:04 HumanG33k @challgren where can i found the $this->request->input options list ?
# Jan 20th, 09:59 marek.sebera While setting up tests, is it possible to generate fixtures for all models, without manually specifying each one?
# Jan 20th, 09:56 HumanG33k i need to change it to arry
# Jan 20th, 09:55 HumanG33k @challgren error 500
# Jan 20th, 09:52 val What would be the best approach in overriding QueryBuilder in 3.x?
# Jan 20th, 09:49 challgren https://book.cakephp.org/4/en/controllers/request-response.html#xml-or-json-data
# Jan 20th, 09:44 challgren Hold please
# Jan 20th, 09:44 HumanG33k yes
# Jan 20th, 09:44 challgren Wait are you on 4?
# Jan 20th, 09:44 challgren Drop the country object and just do name
# Jan 20th, 09:43 HumanG33k and this is the curl request
# Jan 20th, 09:43 HumanG33k curl -i -H "Accept: application/json" -X POST -d "{'country': {'name': 'England'}}";
# Jan 20th, 09:41 HumanG33k @challgren https://paste.debian.net/1126761/ the data value
# Jan 20th, 09:40 alexdd55976 morning fellows
# Jan 20th, 09:40 challgren debug($this->request->getData());
# Jan 20th, 09:39 challgren Whats your request data look like?
# Jan 20th, 09:39 HumanG33k the entity is save without my data
# Jan 20th, 09:39 challgren But your saying its not saving the data, correct?
# Jan 20th, 09:38 HumanG33k @challgren $country->getErrors() is an empty array
# Jan 20th, 09:37 javier.villanueva morning all
# Jan 20th, 09:32 challgren Id say put it around line 8
# Jan 20th, 09:32 challgren does debug($country->getErrors()) output anything?
# Jan 20th, 09:31 HumanG33k @challgren all exept id
# Jan 20th, 09:28 challgren Yep, what fields do you have accessible in the CountryEntity
# Jan 20th, 09:27 HumanG33k because i have the same behavior