backup_instance()
The backup instance utils create a backup of your HelPHP instance
including the main db indicated in the db config (not the central one if it exist)
backup_instance(mixed $target) : string
can be called from cli with instance path as argument:
php helphp/utils/backup.php instance_home_path
Parameters
-
$target
: mixed
-
beautify_module_list()
beautify_module_list is used during install or uninstall module to insert suppress
module configuration into module list config in main.php file...
it just do the job to keep is readable .
beautify_module_list(mixed|array<string|int, mixed> $module_list, mixed|array<string|int, mixed> $temporary_module) : array<string|int, mixed>
And if you're asking what is $temporary_module ?
It's a surprise ;) job in progress..
Parameters
-
$module_list
: mixed|array<string|int, mixed>
-
-
$temporary_module
: mixed|array<string|int, mixed>
-
Return values
array<string|int, mixed>
—
the module list beautified
check_replication()
The check replica utils is checking is the master slave replication is still operationnal.
check_replication(mixed $target) : string
the user used for connection must have "SUPER" or "SLAVE MONITOR" privilege
can be called from cli with instance path as argument:
php helphp/utils/check_replica.php instance_home_path
Parameters
-
$target
: mixed
-
the home path of the instance to get db config
make_constants_js()
The constants utils is used to make/update a js file with all needed constants
like some translations, basic context infos etc, anything that is necessary to make
run js parts of modules and helPHP js libs
make_constants_js(mixed $target) : string|files
can be called from cli with instance path as argument:
php helphp/utils/constants.php instance_home_path
Parameters
-
$target
: mixed
-
the home path of the instance to get config
Return values
string|files
—
echoing results and js/constants*.js files in the instance.
convert_module()
convert_module(mixed $module_path, mixed $module_name) : mixed
Parameters
-
$module_path
: mixed
-
-
$module_name
: mixed
-
upgrade()
upgrade(mixed $public_admin, mixed $old_module_name, mixed $module_name, mixed $old_file, mixed $new_file) : mixed
Parameters
-
$public_admin
: mixed
-
-
$old_module_name
: mixed
-
-
$module_name
: mixed
-
-
$old_file
: mixed
-
-
$new_file
: mixed
-
get_string_between()
get_string_between(mixed $string, mixed $start, mixed $end) : mixed
Parameters
-
$string
: mixed
-
-
$start
: mixed
-
-
$end
: mixed
-
create_module()
create a basic module for helPHP
create_module(string $module_name) : string
To call from CLI
php create_module.php module_name
Parameters
-
$module_name
: string
-
make_install()
create everything needed for installing a module
make_install(string $module_name, string $object_list[, bool $sql_only = false ][, mixed $public = true ]) : string
Will create the file install.php with sql query and list of file needed inside.
Will also create both index.php for admin and public
To call from CLI
php create_module_installer.php module_name sql_object1,sql_object2,... true|false
if the module has no db
php create_module_installer.php module_name no_db
Parameters
-
$module_name
: string
-
-
$object_list
: string
-
sql object of the module name separated by a ','
-
$sql_only
: bool
= false
-
Optional. True, only create the sql part, ignore file
-
$public
: mixed
= true
-
recurse_ls()
to get the list of file and folder
recurse_ls(mixed $path[, mixed $base_path = '' ]) : mixed
modified version of filesystem.php to also be used by CLI call
Parameters
-
$path
: mixed
-
-
$base_path
: mixed
= ''
-
generate_index()
generate_index(mixed $module_name, mixed $path, mixed $public) : mixed
Parameters
-
$module_name
: mixed
-
-
$path
: mixed
-
-
$public
: mixed
-
beautify_db_writing()
beautify_db_writing(mixed $str) : mixed
Parameters
-
$str
: mixed
-
create_object_sql_from_table()
Create the json file describing a table in generated/sql_objects
create_object_sql_from_table(string $instance_path, string $table_name[, mixed $CLI = false ]) : string
To call from CLI
php create_object_sql_from_table.php instance_path table_name
Parameters
-
$instance_path
: string
-
-
$table_name
: string
-
-
$CLI
: mixed
= false
-
export_data_sql_to_json()
Return a json describing all the entries in a table
export_data_sql_to_json(string $instance_path, string $table_name) : string
To call from CLI
php export_data_sql_to_json.php instance_path table_name
Parameters
-
$instance_path
: string
-
-
$table_name
: string
-
install_blocks()
Install all blocks found in modules/block folder from helPHP framework
install_blocks(mixed $instance_path) : string
To call from CLI :
php install_blocks.php /path/to/my/instance/
Parameters
-
$instance_path
: mixed
-
install_instance()
install_instance(mixed $home_folder, mixed $admin_user, mixed $admin_pass, mixed $db_root_user, mixed $db_root_pass, mixed $db_root_user_central, mixed $db_root_password_central, mixed $db_root_user_slave, mixed $db_root_password_slave) : mixed
Parameters
-
$home_folder
: mixed
-
-
$admin_user
: mixed
-
-
$admin_pass
: mixed
-
-
$db_root_user
: mixed
-
-
$db_root_pass
: mixed
-
-
$db_root_user_central
: mixed
-
-
$db_root_password_central
: mixed
-
-
$db_root_user_slave
: mixed
-
-
$db_root_password_slave
: mixed
-
install_module()
Install a module in the instance and add a menu in admin hierarchy
install_module(mixed $instance_path, mixed $module_name[, bool $ignore_file_and_folder = false ]) : string
To call from CLI :
php install_module.php /path/to/my/instance/ module_name
Parameters
-
$instance_path
: mixed
-
-
$module_name
: mixed
-
-
$ignore_file_and_folder
: bool
= false
-
super_copy()
super_copy(mixed $source, mixed $target, mixed $user, mixed $groupe) : mixed
Parameters
-
$source
: mixed
-
-
$target
: mixed
-
-
$user
: mixed
-
-
$groupe
: mixed
-
super_mkdir()
super_mkdir(mixed $target, mixed $right, mixed $user, mixed $groupe) : mixed
Parameters
-
$target
: mixed
-
-
$right
: mixed
-
-
$user
: mixed
-
-
$groupe
: mixed
-
job_manager()
here is our buddy the job manager, made to be run as a command an working with "jobs" database as a job pile.
job_manager(mixed $argv) : mixed
arguments :
-k , to identify the job
-C , callback when command is done
-c , the command to execute
-f , path to the instance
-a , action for the job manager (new, progress or cancel)
exemples :
-
add a job :
$job_manager_call='php /home/helphp/utils/job_manager.php -a"new" -f"'.$from.'" -c"'.$cmd.'" -C"'.$callback.'" -k"'.$key.'"';
-
get progress :
$job_manager_call='php /home/helphp/utils/job_manager.php -a"progress" -f"'.$from.'" -k"'.$key.'"';
-
cancel :
$job_manager_call='php /home/helphp/utils/job_manager.php -a"cancel" -f"'.$from.'" -k"'.$key.'"';
must be followed by : exec($job_manager_call);
Parameters
-
$argv
: mixed
-
new_job()
to add a new job in "jobs" database pile
new_job(mixed $from, mixed $command, mixed $callback, mixed $key) : void
Parameters
-
$from
: mixed
-
-
$command
: mixed
-
-
$callback
: mixed
-
-
$key
: mixed
-
the key identifier that permit to follow th process.
cancel_job()
Cancel a job and move if from db to history
cancel_job(mixed $from, mixed $key) : void
Parameters
-
$from
: mixed
-
-
$key
: mixed
-
indentifier of the job to cancel.
set_status_job()
Change the status of a job in the pile.
set_status_job(mixed $from, mixed $key, mixed $status) : void
Parameters
-
$from
: mixed
-
-
$key
: mixed
-
-
$status
: mixed
-
possible values :
- 0 undone
- 1 in progress
- 2 done
- 3 error
get_job_progress()
Get the progression of a job
get_job_progress(mixed $from, mixed $key) : string
Parameters
-
$from
: mixed
-
-
$key
: mixed
-
Return values
string
—
messages / echo from the process if it got status = 1 (1 in progress)
- status 0 : it will return "wait"
- status 2 : "ok!" because finished
- status 3 : "err" an error happenned.
job_loop()
The job loop will run until there is no more job to do, so it must be started at start or the server
and it will go on infine loop waiting for job to execute.
job_loop() : void
minify()
Minify an instance : Take all js files to create only one js.gz file
the same for the CSS theme.
minify(string $target) : string|files
At the end you'll get only two small files instead of 30/40~ and with a size reduced by ten.
of course the impact on speed is huge and as the number or http queries is reduced the server ressource are increased by 20 ~ !
After minifying, you just need to swith DEVMODE to false in your main config file to see the difference.
it's common practices to keep one version of the instance as a dev version and the second as production.
in that case you just need to move css/gz/* and jsgz/* files from dev version to prod + database
Parameters
-
$target
: string
-
the home path of the instance to get config
Return values
string|files
—
echoing results of minification.
writeUTF8File()
writeUTF8File(mixed $filename, mixed $content) : mixed
Parameters
-
$filename
: mixed
-
-
$content
: mixed
-
process_launcher()
launch process in background and store their progress in redis,
it's a subprocess script for helPHP\libs\utils\system_process_to_redis
process_launcher(array<string|int, mixed> $argv) : mixed
must be launch from cli with arguments
can be used also to "force cancel" a job when type of process is "job",
it's a special case when we want to create easily some "cancel" button for job in progress
Parameters
-
$argv
: array<string|int, mixed>
-
the arguments of the cli command :
argument Options:
-k , the key to identify the process in redis
-t , the type of the process
-a , params depending the type
-l , list of files that need to be locked during the process
-i , path to the instance
-
see
-
system_process_to_redis
uninstall_module()
Uninstall a module in the instance and
uninstall_module(mixed $instance_path, mixed $module_name[, bool $ignore_file_and_folder = false ][, mixed $CLI = false ]) : string
To call from CLI :
php uninstall_module.php /path/to/my/instance/ module_name
Parameters
-
$instance_path
: mixed
-
-
$module_name
: mixed
-
-
$ignore_file_and_folder
: bool
= false
-
-
$CLI
: mixed
= false
-