# |
Mar 7th 2018, 10:42 |
richellyitalo |
Nice tip....I will setup only in routes api. |
# |
Mar 7th 2018, 10:42 |
neon1024 |
If you have a web service and http on the same application, be sure you don’t set all your requests to application/json! :P |
# |
Mar 7th 2018, 10:42 |
richellyitalo |
ok...thanks , very helpfull |
# |
Mar 7th 2018, 10:41 |
neon1024 |
Just check the url and then you can use something like `$request = $request->withHeader('Content-Type', 'application/json')` |
# |
Mar 7th 2018, 10:40 |
neon1024 |
Middleware sounds very complicated, but is actually very simple |
# |
Mar 7th 2018, 10:40 |
richellyitalo |
Ok, no problem. |
# |
Mar 7th 2018, 10:40 |
neon1024 |
https://book.cakephp.org/3.0/en/controllers/middleware.html |
# |
Mar 7th 2018, 10:40 |
neon1024 |
It’s part of my work, so I’m not allowed to share it, sorry |
# |
Mar 7th 2018, 10:39 |
richellyitalo |
Do you have the code or article with this solutions? |
# |
Mar 7th 2018, 10:39 |
neon1024 |
@richellyitalo Well I solved that problem using a middleware class, which automatically adds the headers I need to the request |
# |
Mar 7th 2018, 10:38 |
richellyitalo |
@neon1024 So I can't make the server works /users normally to return json without content-type ? |
# |
Mar 7th 2018, 10:35 |
dereuromark |
willem: i use an enhanced version of it that a lot of things on top, but yeah |
# |
Mar 7th 2018, 10:35 |
neon1024 |
You set the headers in the request you send your endpoint |
# |
Mar 7th 2018, 10:35 |
willem |
@dereuromark this one right? https://github.com/World-Architects/cakephp-fixture-check |
# |
Mar 7th 2018, 10:34 |
richellyitalo |
How can I do that? |
# |
Mar 7th 2018, 10:34 |
neon1024 |
@richellyitalo Sure you can, but you’ll have to pass the correct Content-Type headers |
# |
Mar 7th 2018, 10:34 |
richellyitalo |
without json |
# |
Mar 7th 2018, 10:33 |
richellyitalo |
example: `/users.json` like this `/user` |
# |
Mar 7th 2018, 10:33 |
richellyitalo |
I wanna be know if I can remove format from REST in route. |
# |
Mar 7th 2018, 10:33 |
willem |
fixture_check -> is this a plugin ? |
# |
Mar 7th 2018, 10:32 |
neon1024 |
@richellyitalo Can you be more specific? What aspects of REST? |
# |
Mar 7th 2018, 10:32 |
dereuromark |
just randomly adding them without test backup is usually causing more trouble. |
# |
Mar 7th 2018, 10:32 |
dereuromark |
they are helpful for data integrity, but only if applied in a sane way. |
# |
Mar 7th 2018, 10:31 |
willem |
so foreign key relations are not really needed in the db? somehow i thought that would be better |
# |
Mar 7th 2018, 10:31 |
willem |
yes, ok, will check the fixture check. good tip. |
# |
Mar 7th 2018, 10:31 |
richellyitalo |
Can someone help with REST? |
# |
Mar 7th 2018, 10:31 |
richellyitalo |
Hello. |
# |
Mar 7th 2018, 10:30 |
dereuromark |
or even worse continue deploying and crashing then on production after the fact |
# |
Mar 7th 2018, 10:30 |
dereuromark |
one field missing can be the difference that will bring the deployment to a crash |
# |
Mar 7th 2018, 10:30 |
dereuromark |
One of my most important console shells these days: bin/cake fixture_check => sync fixtures to DB schema |
# |
Mar 7th 2018, 10:29 |
dereuromark |
And also important: The fixtures need to 100% reflect that and contain good default data. This will prevent it by design, as the tests will then fail early on before you even start to deploy anything. |
# |
Mar 7th 2018, 10:27 |
neon1024 |
But I think you need pretty solid validation and rules in your application |
# |
Mar 7th 2018, 10:27 |
neon1024 |
I haven’t had too many issues when I have used foreign key constraints though |
# |
Mar 7th 2018, 10:27 |
neon1024 |
I don’t actually know what the official line is with Cakephp and foreignkey constraints, and those ON UPDATE DELETE etc |
# |
Mar 7th 2018, 10:26 |
dereuromark |
I am careful with those too |
# |
Mar 7th 2018, 10:25 |
neon1024 |
Well I don’t use foreign key constraints, so I’ve never had this issue, sorry |
# |
Mar 7th 2018, 10:18 |
willem |
thought it would be plugandplay but i have to check the order of statements manually? |
# |
Mar 7th 2018, 10:18 |
willem |
problem is when it fails midway i cannot rollback |
# |
Mar 7th 2018, 10:17 |
willem |
which uses the up() method |
# |
Mar 7th 2018, 10:15 |
willem |
no wait, sorry, I create a diff which creates a migration file with all changes |
# |
Mar 7th 2018, 10:15 |
neon1024 |
If you’re executing empty migrations, they should work! :P |