CakePHP 5.1.0 introduced support for geospatial types, but for now it’s limited. Here’s how you can read and write these values easily.
“Authentication is required to continue” when loading Authentication component
If you use cakedc/users or cakephp/authentication and want to programmatically log in a newly created user, you will have to use setIdentity() on Authentication component, and for that you will have to load it into your controller. But if you do it wrong, you will get this error: Authentication is required to continue Authentication\Authenticator\UnauthenticatedException To… Continue reading “Authentication is required to continue” when loading Authentication component
Cleaning up multiple logs in a folder
LEts say you have to manually look through a bunch of log files to do a check on something. To make the job easier, you can clean up those logs from the lines you know you don’t need, significantly reducing the amount of stuff you have to go through. sed -i '#192.168.1.1#d' /tmp/*.log Here we’re… Continue reading Cleaning up multiple logs in a folder
Optional parameter in named routes
Let’s say you want to make a named CakePHP route which may or may not have an argument. For example, you want to return WHOIS information for an IP address: /whois/1.1.1.1 returns WHOIS information for 1.1.1.1 which is specifically passed in the URL; /whois will return WHOIS information for the visitor’s IP address. When doing… Continue reading Optional parameter in named routes
Changing request IP address for debugging in CakePHP
If you’re working on a feature that acts differently based on the request IP address, you would be wanting to test it continuously. For that, you may have to have your application think you’re accessing it from a specific/different IP address. The easiest way would be to just store the IP in a variable and… Continue reading Changing request IP address for debugging in CakePHP
Finding deployment ID or commit hash with Azure Web Apps Node.JS
You deploy your Node.js code to Azure Web Apps. In your code, you want to know the latest deployment commit ID/hash. Since Azure does not keep the information in environment variables, we will need to call a custom script on each build from package.json.
Deploying a Node.JS application to Azure Web App Service
If you deployed your Node.JS app to Azure and you can’t get it to run, a common gotcha is the port number your app is listening on. When troubleshooting, you may be reading that Azure allows incoming connections only to ports 80 and 443. So you make your app listen to 80 or 443, but… Continue reading Deploying a Node.JS application to Azure Web App Service
Searching for code snippets in a given directory
One thing that saved me lots of time and potential bugs is using grep for a given string in a given directory. Imagine you decided to rename a function and you now need to update every piece of code that calls it. No chance you will remember all places where you used it, and manually… Continue reading Searching for code snippets in a given directory
Certbot deploy-hook command not found
If you want certbot-auto to reload nginx after issuing or renewing a certificate, you may want to use –deploy-hook. But if you put the plain service nginx reload there, it may actually fail to renew, and you would get the following error in your /var/log/letsencrypt/letsencrypt.log: deploy-hook command "service nginx reload" returned error code 127 Error… Continue reading Certbot deploy-hook command not found
CRUD View: _getIndexTitleField() must be of type string, array returned
Setup You’re using CakePHP with CRUD plugin installed. You baked some models from the database. Problem You visit the index page for a given model and you get the following error: CrudView\Listener\ViewListener::_getIndexTitleField(): Return value must be of type string, array returned Solution Make sure the model has a display field. You can always try using… Continue reading CRUD View: _getIndexTitleField() must be of type string, array returned