How to Debug in Jalno
Debugging a request falls into the following two categories, depending on its type:
1. CLI Requests
Requests that are executed through the command line (Terminal), and processes in general, are of this type. Debugging this type of request is easier.
The packages\base\Exception Exception
If you receive an exception in the response while executing a request through the command line, then depending on the exception message, it can have one of the following causes:
The Could not find process error message
As is clear from the error message, this means that the framework could not find the class or method specified for execution. To resolve this issue, first check the path of the specified class; if it is correct, make sure the Process file is registered in the Autoloader.
The Process #1 already running error message
This error occurs when a process is called using its ID. If the process is already running, the framework throws an exception with this error message in the response and prevents it from being run again. If you are certain that this process has stopped and you intend to run it again, change the process's status in the base_processes table to 0.
The packages\base\notShellAccess Exception
If your operating system is not part of the Linux family, or the execution of the shell_exec method is prevented by the PHP settings, you receive this exception.
To resolve this, make sure the shell_exec method is not present in the disable_functions setting in the PHP configuration file (the php.ini file).
2. CGI (HTTP) Requests
If you receive the packages\base\NotFound error while executing a request, you can find the source of the problem by taking one of the following actions:
Make sure the package is enabled.
For a package to be loaded by the framework and its rules to be read, a package.json file conforming to the framework's rules must exist in the package.
Make sure the Router file is registered.
You must have specified the file name in the router option in the package configuration file Package.json.
Check the rule defined in the Router.
Sometimes you may receive this error because of a mismatch between the path defined in the router file and the path that was requested.
Check the specified controller:
The packages\base\NotFound exception may have been thrown by the controller. Check the controller and its conditions.
To make sure the request has reached the controller invocation stage, you can throw an arbitrary exception or print some text for display.
However, if you have encountered the Packages\base\NoViewException exception in the request response, you should check the View file(s).
When you specify a View file via the SetView method in the controller's response, if the specified file is not recognized by the framework or it cannot find it, the framework throws this exception.
If the specified View is not one of the theme's views, its corresponding View must be registered in the theme and in the theme configuration file (the Theme.json file); otherwise, even though the classes are recognized, this exception is still thrown.
If you receive an empty response and a blank page is displayed in your browser, one of the following situations may have occurred:
The View file is not specified in the response:
In the controller, a View must be specified in the response. For this purpose, you must use the SetView method of the Response class.
use packages\base\{Response, View};
use packages\userpanel\{Controller, views};
class Login extends Controller {
public function signup(): Response {
$view = View::byName(views\Register::class);
$this->response->setView($view);
// Or $this->response->setView(View::byName(views\Register::class));
$this->response->setStatus(true);
return $this->response;
}
}
The HTML file is not specified:
Even though the Views are specified, if the HTML file is not recognized by the framework, an empty response is sent to you and a blank page is displayed.
To register the HTML file, you can either register it in the theme configuration file (the Theme.json file), or create a file exactly identical to the View file in the theme's path, inside the html folder. The framework automatically connects the View and the HTML together.
{
"name" : "clipone",
"title":"Clip-One",
"version" : "1.4.0",
"views": [
{
"name":"\\themes\\clipone\\views\\register",
"parent":"packages\\userpanel\\views\\register",
"file":"html/register.php"
}
]
}
You have received an error or exception:
If error display is turned off in the framework, the error is not shown in your response and you receive an empty response.
To display errors, you can enable PHP error display in the Index.php file. And to display exceptions, in the same file, in the catch section, you must print the exception's error for display.
It is never recommended to keep error or exception display enabled when the site is publicly available for use.