Blog
- Details
- Written by R. Elizondo
- Category: Cheat Sheets
Here's a comprehensive cheat sheet of Docker commands along with an example of each one. If you need more details on a particular command, just type the command and --help.
docker version
Display the Docker client and server versions.
$ docker version
docker info
Display system-wide information about Docker.
$ docker info
- Details
- Written by R. Elizondo
- Category: Cheat Sheets
Here's a cheat sheet of Docker Compose commands along with an example of each one.. If you need more details on a particular command, just type the command and --help.
docker-compose up
Create and start Docker containers defined in a docker-compose.yml file.
$ docker-compose up
docker-compose down
Stop and remove Docker containers defined in a docker-compose.yml file.
$ docker-compose down
- Details
- Written by R. Elizondo
- Category: PHP Software Development
PHP has a wide range of capabilities, including the ability to execute Linux commands directly from PHP scripts. This functionality allows PHP developers to interact with the underlying operating system, execute system commands, and retrieve the output for further processing.In this article, we will explore different methods and examples of executing Linux commands from PHP.
Using the exec() Function:
The `exec()` function in PHP allows you to execute Linux commands and retrieve the output. Here's a simple example:
//...
$command = 'ls -l';
$output = exec($command);
echo $output;
//...
In this example, the `ls -l` command is executed, and the output is stored in the `$output` variable. Finally, the output is displayed using the `echo` statement.
- Details
- Written by R. Elizondo
- Category: PHP Software Development
Image scaling is a common requirement in web development, allowing you to resize and adjust the dimensions of an image according to your needs. PHP provides various functions and libraries that enable you to scale images easily. In this article, we will explore some examples and techniques for scaling images in PHP.
Using the GD Library:
The GD library is a popular PHP extension that provides a wide range of image manipulation functions. To scale an image using GD, you can utilize the `imagecopyresampled()` function. Here's an example:
//...
// Load the original image
$originalImage = imagecreatefromjpeg('original.jpg');
// Define the new dimensions
$newWidth = 800;
$newHeight = 600;
// Create a new image with the desired dimensions
$newImage = imagecreatetruecolor($newWidth, $newHeight);
// Scale the original image to the new dimensions
imagecopyresampled($newImage, $originalImage, 0, 0, 0, 0, $newWidth, $newHeight, imagesx($originalImage), imagesy($originalImage));
// Save the scaled image to a file
imagejpeg($newImage, 'scaled.jpg');
// Free up memory
imagedestroy($originalImage);
imagedestroy($newImage);
//...
In this example, we first load the original image using `imagecreatefromjpeg()`. Then, we define the new dimensions for the scaled image. Using `imagecreatetruecolor()`, we create a new image with the desired dimensions. The `imagecopyresampled()` function scales the original image to the new dimensions and stores the result in the new image. Finally, we save the scaled image using `imagejpeg()`, and free up the memory using `imagedestroy()`.
Page 18 of 42