# |
Jun 7th 2021, 06:47 |
peter.harder |
I want to redirect http to https and ```HttpsEnforcerMiddleware``` works excellent for that. But - I have one (1) controller that serves a legacy Windows-application that do not support https. Can I exclude this specific controller from being redirected? I can’t find any built in way for this, like the $csrf->skipCheckCallback. To solve it for now, I made my own copy of HttpsEnforcerMiddleware and added a |
# |
Jun 7th 2021, 06:47 |
slackebot |
“whiteList” array to pass to the constructor. It seem to work, but there might be a better way? |
# |
Jun 6th 2021, 21:02 |
haldiainftech01 |
hi, club room (Chat) application idea |
# |
Jun 6th 2021, 21:01 |
haldiainftech01 |
hi |
# |
Jun 6th 2021, 20:47 |
kevin.pfeifer |
ok, then i tested it wrong :,) |
# |
Jun 6th 2021, 20:45 |
kupe3b |
thanks ``` 'Error' => [ 'errorLevel' => E_ALL and ~E_NOTICE, ],``` in app_local.php is what i needed. |
# |
Jun 6th 2021, 20:34 |
kevin.pfeifer |
well, debug mode is meant to show you all that is either deprecated or if there are problems with your code. I am not aware that this is possible when debug mode is active. There is a line in your app.php (or app_local.php) where you can set the active error levels https://github.com/cakephp/app/blob/master/config/app.php#L183 but this doesn’t do what you want |
# |
Jun 6th 2021, 20:11 |
kupe3b |
and without switching debug to false |
# |
Jun 6th 2021, 20:11 |
kupe3b |
hi, anyone knows how can i disable PHP notices from cakephp (without changing php.ini)? |
# |
Jun 6th 2021, 18:12 |
kevin.pfeifer |
well, as always, there are many ways you can do such a thing. I did it via a GET form (so the filter parameters are present in the URL) and check them in my controller/custom finder method via something like that ```$filter_connection_type = $current_request->getQuery( 'filter_connection_type' ); if( $filter_connection_type != 'all' andand !is_null( $filter_connection_type ) ) { $query->distinct( [ |
# |
Jun 6th 2021, 18:12 |
slackebot |
'FtpLoginData.id' ] ) ->matching( 'ConnectionTypes', function( $q ) use ( $filter_connection_type ) { /** @var $q Query */ return $q->where( [ 'ConnectionTypes.id' => $filter_connection_type ] ); } ); }``` But if you use the friendsofcake/search plugin there are different ways how you adjust the query |
# |
Jun 6th 2021, 18:06 |
etibor |
okey thank you, @kevin.pfeifer so basically for a filter form page there is not necesserly to check the request method |
# |
Jun 6th 2021, 18:03 |
kevin.pfeifer |
therefore if you call `/categories/add` "normally" (= GET method) you get the add form and when the form is being submited via POST to the same URL it actually saves the data |
# |
Jun 6th 2021, 18:02 |
kevin.pfeifer |
thats why e.g. the add function has only the save logic inside such an if ``` public function add() { $category = $this->Categories->newEmptyEntity(); if( $this->request->is( 'post' ) ) { $category = $this->Categories->patchEntity( $category, $this->request->getData() ); if( $this->Categories->save( $category ) ) { $this->Flash->success( __( 'The category has been saved.' ) ); return |
# |
Jun 6th 2021, 18:02 |
slackebot |
$this->redirect( [ 'action' => 'index' ] ); } $this->Flash->error( __( 'The category could not be saved. Please, try again.' ) ); } $this->set( compact( 'category' ) ); }``` |
# |
Jun 6th 2021, 18:01 |
kevin.pfeifer |
controller functions basically don't care from which HTTP method they are called. You can restrict logic inside your controller functions with something like that ```if( $this->request->is( 'get' ) ) { // Code only executed on GET requests } if( $this->request->is( 'post' ) ) { // Code only executed on POST requests } // Code executed for ALL HTTP methods``` |
# |
Jun 6th 2021, 17:57 |
etibor |
is there a universal request method for handling post and get like the $_REQUEST in core php? |
# |
Jun 6th 2021, 17:10 |
kevin.pfeifer |
:wave: |
# |
Jun 6th 2021, 17:08 |
etibor |
hello everyone |
# |
Jun 6th 2021, 14:17 |
fresnel.brieuc |
Yup, thanks |
# |
Jun 6th 2021, 14:16 |
isvyas |
@fresnel.brieuc complication is handled by Laravel mix: https://laravel-mix.com/ Which you can find in package.json file. |
# |
Jun 6th 2021, 14:16 |
fresnel.brieuc |
I have no idea what I'm doing wow |
# |
Jun 6th 2021, 14:02 |
fresnel.brieuc |
Or does vue maybe does that automatically? |
# |
Jun 6th 2021, 14:01 |
fresnel.brieuc |
@isvyas Sorry to bother you again but I have a question concerning the repo you sent me yesterday https://github.com/ishanvyas22/cakephpvue-spa, does the config compile components css/scss ? How does it work ? (Not talking about the resources/css directory you made, talking about the css inside vue component files) |
# |
Jun 5th 2021, 19:24 |
etibor |
i think i made a fault by, adding a ```if($this->request->is('post')){ }else{//no form submit }``` |
# |
Jun 5th 2021, 19:18 |
kevin.pfeifer |
so your paginated table was only built when you click on a button which submits a form? |
# |
Jun 5th 2021, 19:08 |
etibor |
i haven properly definied the Form |
# |
Jun 5th 2021, 19:07 |
etibor |
the issue is similiar: ```The reason why the error did not occur when you submit the form is because the $_POST variables exist in the server but if you click the page button IE <a href="search?page=2">2</a> the $_POST will gone That's why this occurs Notice (8): Undefined index: to [APP/Controller/Admin/ScheduleController.php, line 257] to fix that change your method to GET``` |
# |
Jun 5th 2021, 18:56 |
kevin.pfeifer |
so it does happen on page=1 but not on page=2? |
# |
Jun 5th 2021, 18:55 |
etibor |
the issue is probably related to a form filter |
# |
Jun 5th 2021, 18:41 |
etibor |
after the first post it does render the 30 record |
# |
Jun 5th 2021, 18:40 |
etibor |
hm, interestingly it happened when click on the page number |
# |
Jun 5th 2021, 18:26 |
kevin.pfeifer |
well does the array change when you go into your template |
# |
Jun 5th 2021, 18:26 |
etibor |
so it may passed for the view |
# |
Jun 5th 2021, 18:26 |
etibor |
$documents->toArray() shows the 30 record |
# |
Jun 5th 2021, 18:23 |
kevin.pfeifer |
`->count()` is the whole query without limit but `$douments->toArray()` is actually the array whicht gets passed to your view |
# |
Jun 5th 2021, 18:23 |
etibor |
```LIMIT 30 OFFSET 30``` |
# |
Jun 5th 2021, 18:23 |
etibor |
yes you are right @kevin.pfeifer it does got the : ```LIMIT 30 OFFSET 0``` on the first page, while on the second |
# |
Jun 5th 2021, 18:22 |
kevin.pfeifer |
otherwise you result object only has one entry in there? |
# |
Jun 5th 2021, 18:20 |
kevin.pfeifer |
after doing the `->paginate()` function on your query object it should have the limit inside the `->sql()` function |
# |
Jun 5th 2021, 18:17 |
etibor |
thank you @kevin.pfeifer |
# |
Jun 5th 2021, 18:16 |
etibor |
$documents->count() returns 1210 |
# |
Jun 5th 2021, 18:15 |
etibor |
i checked $documents->sql() it does not contain any limit or offset |
# |
Jun 5th 2021, 18:12 |
kevin.pfeifer |
when you check the sql query with debugkit does it say limit 30? |
# |
Jun 5th 2021, 18:06 |
etibor |
and debug($this->paginate); shows limit 30 record / page |
# |
Jun 5th 2021, 18:05 |
etibor |
i dont know whats the reason why pagination return only one record per page, because at the bottom of the page its shows 30 record/page |
# |
Jun 5th 2021, 18:04 |
etibor |
Hello everyone |
# |
Jun 5th 2021, 15:47 |
admad |
Regardless I approve of the tweet for Linkin Park reference :) |
# |
Jun 5th 2021, 15:43 |
ndm |
Not really into crypto either, but yeah, it looks like the game is still on :) |
# |
Jun 5th 2021, 15:42 |
admad |
Oh he did another tweet yesterday :,) |
# |
Jun 5th 2021, 15:39 |
admad |
@ndm I would like to have BS based "official" skeleton but as we have seen that's not achievable with just template changes. |
# |
Jun 5th 2021, 15:37 |
admad |
Not into the crypto scene, the blood bath post Elon shenagins continues? |
# |
Jun 5th 2021, 15:36 |
ndm |
People contemplation with self-deletion after checking their bitcoin wallets? |
# |
Jun 5th 2021, 15:35 |
admad |
I agree |
# |
Jun 5th 2021, 15:28 |
kevin.pfeifer |
looking at https://packagist.org/packages/cakephp/cakephp/stats i wonder what happened last month :thinking_face: |
# |
Jun 5th 2021, 15:03 |
ndm |
I know, but the shipped defaults are just for prototyping anyways... I'd personally would've rather seen the framework's userbase increase by giving the kinds the hip stuff. |
# |
Jun 5th 2021, 15:02 |
kevin.pfeifer |
not only classes but some DOM changes too I guess |
# |
Jun 5th 2021, 15:02 |
dereuromark |
Less easy to move away from again |
# |
Jun 5th 2021, 15:02 |
dereuromark |
The idea Was minimal overhead on the default HTML. Bootstrap requires more class adding ootb |
# |
Jun 5th 2021, 15:00 |
kevin.pfeifer |
I can imagine that this was definitely not an easy decision back then but as you said it wouldn’t matter that much any more I remember the “old” cake 3 default styling was even more “oldstyle” than the current milligram variant in my opinion :) |
# |
Jun 5th 2021, 14:57 |
ndm |
Doesn't really matter anymore now though, that horse is already in a tube of glue. It would've mattered back then, but now, I don't think Bootstrap would attract many new users. |
# |
Jun 5th 2021, 14:55 |
ndm |
and foundation, yeah... which is less esoteric, but still not even closely as popular as bootstrap, at least that was the case back then, not sure how it's nowadays. |
# |
Jun 5th 2021, 14:53 |
kevin.pfeifer |
you mean miligram as esoteric? |
# |
Jun 5th 2021, 14:52 |
ndm |
Still a pity IMHO that CakePHP chose the esoteric frameworks instead... going with Bootstrap would have been way more popular. But that's a different topic I guess. |
# |
Jun 5th 2021, 14:50 |
ndm |
Understandable... I was never a fan of the "frontend" pages made with bootstrap to begin with, but for "backends" I don't mind it. |
# |
Jun 5th 2021, 14:47 |
kevin.pfeifer |
but I worked with and looked at so many bootstrap pages that I just can’t stand them any more |
# |
Jun 5th 2021, 14:47 |
kevin.pfeifer |
im sorry ,:) |
# |
Jun 5th 2021, 14:43 |
ndm |
You're welcome... even after learning that you're a bootsrap-ophobe :P |
# |
Jun 5th 2021, 14:38 |
kevin.pfeifer |
ok, then I will do that :) thx |
# |
Jun 5th 2021, 14:36 |
ndm |
the browsers I mean |
# |
Jun 5th 2021, 14:36 |
ndm |
Or maybe they wouldn't... sensitive data and what not. |
# |
Jun 5th 2021, 14:35 |
ndm |
In a perfect world browsers would offer such functionality out of the box I guess... anyways, sure, why not, generally reasonable I guess :) I'd say it's a good fit for a component, it knows about the request object, you can inject the additional model dependency so that it can create entities with the data from the cookie, and you let it manually know (when your save succeeds) that you want the cookie to be set/updated. |
# |
Jun 5th 2021, 14:31 |
kevin.pfeifer |
OK, the full example is the following: I am in a choir and created a registration page for our choir members to “register” on each choir practice with name, email and phone because we need the info if one of our members has COVID. Since we have lazy ass members they now asked me if I can “save” their data without the need of them creating an account on my page so they don’t need to fill out those 3 input fields |
# |
Jun 5th 2021, 14:31 |
slackebot |
(yea, i know) So I thought well, lets create a cookie with a 1 year lifespan or something stupid. |
# |
Jun 5th 2021, 14:27 |
ndm |
Well, it's definitely not something that should be in your model in any way shape or form, that's really not it's concern. Whether the concept makes sense... depends I'd say, on what kind of data it is, why it needs to seemingly survive across sessions, etc. |
# |
Jun 5th 2021, 14:24 |
kevin.pfeifer |
or is this a horrible idea :) |
# |
Jun 5th 2021, 14:19 |
kevin.pfeifer |
basically I want to provide prefilled data for users who have already entered a specific form. And I thought I could add a cookie with the filled in data on save, check for that cookie when loading the page and prefill the form with that data |
# |
Jun 5th 2021, 14:14 |
ndm |
If you let us know what that cookie is good for, you may get a better answer :upside_down_face: |
# |
Jun 5th 2021, 14:13 |
kevin.pfeifer |
ok, was just curious :) |
# |
Jun 5th 2021, 14:12 |
ndm |
Given that the model layer in CakePHP apps is usually just ORM, yeah, that's not something that your model should do, or even know about in the first place. |
# |
Jun 5th 2021, 14:06 |
kevin.pfeifer |
or should cookie logic always be present in the controller? |
# |
Jun 5th 2021, 14:04 |
kevin.pfeifer |
is it possible to set a Cookie inside a beforeSave hook in the model? Currently I only find ways to set cookies via the request object which I can’t access in the model |
# |
Jun 5th 2021, 11:26 |
fresnel.brieuc |
Thank you so much ! Exactly what I needed :) |
# |
Jun 5th 2021, 11:24 |
slackebot |
contributor @markstory, • https://github.com/markstory/cakephp-typescript-react • https://github.com/markstory/docket-app Above projects are more than enough for you to get understanding I hope. |
# |
Jun 5th 2021, 11:24 |
isvyas |
Hi @fresnel.brieuc, there's one repo that I've created to demonstrate CakePHP3 + Vue. Currently vue.js version is 2 but general idea would be the same for vue3 or react. • CakePHP + Vue: https://github.com/ishanvyas22/cakephpvue-spa Above project uses https://github.com/ishanvyas22/asset-mix plugin which makes using modern frontend with CakePHP a breeze. There's also couple of projects for CakePHP + React from core CakePHP |
# |
Jun 5th 2021, 09:19 |
fresnel.brieuc |
Kinda new on making front-end and back-end frameworks together |
# |
Jun 5th 2021, 09:17 |
fresnel.brieuc |
Hello there. I'm trying to use Cake4 + Vue3 and I can't find many resources on how to integrate vue properly with cake. Right now I have to build my vue project and copy/paste the production build into Cake webroot... does any one know of a tutorial on a clean way to do this ? Maybe a tutorial on how to integrate a js framework into cake, if there's none about vue specifically ? |
# |
Jun 4th 2021, 19:40 |
kevin.pfeifer |
:+1: no problem |
# |
Jun 4th 2021, 19:40 |
aengblom |
Makes sense to me now! I am working on an existing application that already had this incorporated into it. I didn't fully understand it. Today came the day where I actually had to worry about translations, lol. Thank you so much for your help and kindness! |
# |
Jun 4th 2021, 19:38 |
kevin.pfeifer |
To explain what each file does: *default.pot* is basically just a template file for what can be translated in whatever language you desire *default.po* is the editable translation file for your desired language *default.mo* is the compiled translation file which cakephp actually reads |
# |
Jun 4th 2021, 19:37 |
aengblom |
Thank you, Kevin! This helps a ton! I think I understand it now. |
# |
Jun 4th 2021, 19:36 |
kevin.pfeifer |
so the process would be like 1. generate new `default.pot` file with `bin/cake extract` 2. update already present `default.po` (no t at the end!) with the new `default.pot` file via PoEdit 3. Translate your new strings 4. Save the `default.po` file so PoEdit generates a new `default.mo` 5. Check if strings are translated as you desire in your app 6. If not, do a `bin/cake cache clear_all` |
# |
Jun 4th 2021, 19:34 |
aengblom |
Ok, gotcha |
# |
Jun 4th 2021, 19:33 |
kevin.pfeifer |
which you then can translate |
# |
Jun 4th 2021, 19:33 |
kevin.pfeifer |
and now it should contain your new strings |
# |
Jun 4th 2021, 19:33 |
kevin.pfeifer |
then select the newly generated default.pot file |
# |
Jun 4th 2021, 19:33 |
kevin.pfeifer |
and select "Update from POT File" |
# |
Jun 4th 2021, 19:32 |
kevin.pfeifer |
then in the menu at top go to "Catalogue" |
# |
Jun 4th 2021, 19:32 |
aengblom |
ok |
# |
Jun 4th 2021, 19:32 |
kevin.pfeifer |
open that with poedit |