This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Author: https://blog.programster.org/creating-phar-files | |
I write lots of helper scripts to do everyday tasks on my computer. These usually start out as BASH scripts, but quite often turn into PHP scripts/tools as they get more complex. For example, I use a PHP CLI tool for a personal password manager. | |
Sometimes a script turn into a "tool" that requires a couple of classes, so I stick them into a folder and have an external BASH script in my $PATH that calls the folders "entrypoint". However, wouldn't it be great if I could just package up the entire folder into a single executable file, much like Java's JAR. This is where the PHAR comes in. | |
If you use PHP you probably use a phar file every day in the form of composer. I had never bothered to learn how to create these files before because I assumed it would be hard, but it's actually easier than I could have believed. | |
Steps | |
Simply create a folder for your project, before creating a folder within there called "app" for your application's source code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json' | |
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="pt-br"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- CSRF Token --> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get memory usage per child process | |
memory_usage_per_child=$(ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d\n", sum/NR/1024) }'); | |
echo | |
echo "Average memory usage per child: ${memory_usage_per_child}MB" | |
# Get total available memory | |
total_available_memory=$(free -m | awk 'NR==2{print $2}'); | |
total_available_memory_gb=$(echo "scale=2; $total_available_memory / 1024" | bc) |
OlderNewer