Introduction
Despite the scorching weather causing discomfort, there’s excitement in the air as our company settles into its new, more spacious office. We trust that all of our team members will have a positive experience this April.
In addition to fostering a healthy work-life balance, the company is committed to enhancing the technical expertise of its members. The upcoming Monthly Tech In event will focus on insights gained from our work on some current projects. The agenda for this meeting includes:
-
Debugging a Magento cronjob
-
Establishing database connections using Sequel Ace (SSH and TCP/IP address)
-
Efficient command operations (Control + E, Control + A, Control + U, Control + R)
Agenda
Debugging a Magento cronjob
Playground script(Recommended)
Create a script with the following content and put it under the pub
folder: testScript.php
We need to access the php debug container with warden debug command(our company uses Warden for development if you are not using Warden, you should know how to debug a command line). After getting inside the container, we run the following command to trigger our script.
We can add the display_errors
parameter to show any errors to output.
Command
We don’t go with detailed steps to create a command in Magento 2. We can use Adobe Plugin to create the CLI command.
We should use ObjectManager in command to have a quick test. Below is a sample code snippet for our command:
netz98
Github: https://github.com/netz98/n98-magerun2
Our intention is to utilize netz98 magerun for debugging and development purposes, rather than as a replacement for Magento CLI commands.
We will put it under Magento root folder.
Establishing database connections using Sequel Ace (SSH and TCP/IP address)
SSH config:
The image below illustrates the sequence of commands that will be executed upon clicking the ‘Connect’ button or when testing the connection.
The initial step involves executing the SSH command to gain access to the server. Once server access is successfully established, the subsequent action entails executing the mysql command to access the MySQL server.
TCP/IP address:
If a MySQL server shares its TCP/IP address, enabling developers to access databases remotely, connecting to the remote database is made straightforward with Sequel Ace.
Filling the database host and the database credentials.
Efficient command operations: Control + E, Control + A, Control + U, Control + R
-
Ctrl + E: Moves cursor to end of current line.
-
Ctrl + A: Moves cursor to beginning of current line.
-
Ctrl + U: Clears text from cursor to beginning of line.
-
Ctrl + R: Initiates reverse search of command history.
Press Ctrl + R again to find next match.
Additionally, you can usehistory
command to find the history.
These commands are commonly used shortcuts that can help improve efficiency and productivity when working in text editors or command line interfaces.