{ "uuid": [ { "value": "cdfbc891-17fa-45e3-9ea6-b0b1bc6defd2" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:57+00:00" } ], "revision_uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "revision_log": [], "status": [ { "value": true } ], "uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "title": [ { "value": "Using a \"run\" file to simplify project tasks" } ], "created": [ { "value": "2022-08-15T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:57+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2022\/08\/15\/using-run-file-simplify-project-tasks", "langcode": "en" } ], "body": [ { "value": "\n
Every project has its own set of commands that need to be run regularly.<\/p>\n\n
From starting a local server or the project's containers with Docker or Docker Compose, running tests or clearing a cache, or generating the CSS and JavaScript assets, these commands can get quite complicated and time-consuming and error-prone to type over and over again.<\/p>\n\n
One common way to simplify these commands is using a A Makefile contains a number of named targets that you can reference, and each has one or more commands that it executes.<\/p>\n\n For example:<\/p>\n\n With this Makefile, I can run Makefiles work well, but I don't use the full functionality that they offer, such as dependencies for targets, and passing arguments to a command - like arguments for a Drush, Symfony Console, or Artisan command, doesn't work as I originally expected.<\/p>\n\n In the example, to pass arguments to the An agency that I worked for created and open-sourced their own Makefile-like tool, written in PHP and built on Symfony Console. I gave a talk on it called Working with Workspace<\/a> and used it on some of my own personal and client projects.<\/p>\n\n The solution that I'm using now is a It's a simple Bash file where you define your commands (or tasks) as functions, and then execute them by typing Here's the Makefile example, but as a As it's Bash, I can just use You can group tasks by having functions like As well as running ad-hoc commands during development, I also use the run file to create functions that run Git pre-commit or pre-push hooks, deploy code with Ansible, or build, push or pull the project's latest Docker images.<\/p>\n\n I also use one within my Talks repository to generate PDF files using rst2pdf, present them using phdpc, and generate thumbnail images.<\/p>\n\n For examples of Every project has its own set of commands that need to be run regularly.<\/p>\n\n From starting a local server or the project's containers with Docker or Docker Compose, running tests or clearing a cache, or generating the CSS and JavaScript assets, these commands can get quite complicated and time-consuming and error-prone to type over and over again.<\/p>\n\n One common way to simplify these commands is using a A Makefile contains a number of named targets that you can reference, and each has one or more commands that it executes.<\/p>\n\n For example:<\/p>\n\n With this Makefile, I can run Makefiles work well, but I don't use the full functionality that they offer, such as dependencies for targets, and passing arguments to a command - like arguments for a Drush, Symfony Console, or Artisan command, doesn't work as I originally expected.<\/p>\n\n In the example, to pass arguments to the An agency that I worked for created and open-sourced their own Makefile-like tool, written in PHP and built on Symfony Console. I gave a talk on it called Working with Workspace<\/a> and used it on some of my own personal and client projects.<\/p>\n\n The solution that I'm using now is a It's a simple Bash file where you define your commands (or tasks) as functions, and then execute them by typing Here's the Makefile example, but as a As it's Bash, I can just use You can group tasks by having functions like As well as running ad-hoc commands during development, I also use the run file to create functions that run Git pre-commit or pre-push hooks, deploy code with Ansible, or build, push or pull the project's latest Docker images.<\/p>\n\n I also use one within my Talks repository to generate PDF files using rst2pdf, present them using phdpc, and generate thumbnail images.<\/p>\n\n For examples of Makefile<\/code>.<\/p>\n\n
# Start the project.\nstart:\n docker-compose up -d\n\n# Stop the project.\nstop:\n docker-compose down\n\n# Run a Drush command.\ndrush:\n docker-compose exec php-fpm drush $(ARGS)\n<\/code><\/pre>\n\n
make start<\/code> to start the project, and
make stop<\/code> to stop it.<\/p>\n\n
drush<\/code> command, I'd have to type
ARGS=\"cache:rebuild\" make drush<\/code> for them to get added and the command to work as expected.<\/p>\n\n
What I'm using now<\/h2>\n\n
run<\/code> file, which is something that I learned from Nick Janetakis' blog and YouTube channel.<\/p>\n\n
.\/run test<\/code> or
.\/run composer require something<\/code>.<\/p>\n\n
run<\/code> script:<\/p>\n\n
#!\/usr\/bin\/env bash\n\nfunction help() {\n # Display some default help text.\n # See examples on GitHub of how to list the available tasks.\n}\n\nfunction start {\n # Start the project.\n docker-compose up -d\n}\n\nfunction stop {\n # Stop the project.\n docker-compose down\n}\n\nfunction drush {\n # Run a Drush command with any additional arguments.\n # e.g. \".\/run drush cache:rebuild\"\n docker-compose exec php-fpm drush \"${@}\"\n}\n\n# Execute the command, or run \"help\".\neval \"${@:-help}\"\n<\/code><\/pre>\n\n
$1<\/code>,
$2<\/code> etc to get specific arguments, or
$@<\/code> to get them all, so
.\/run drush cache:rebuild<\/code> works as expected and any additional arguments are included.<\/p>\n\n
test:unit<\/code> and
test:commit<\/code>, and tasks can run other tasks. I use this for running groups of commands within a CI pipeline, and to extract helper functions for tasks like running
docker-compose exec<\/code> within the PHP container that other commands like
drush<\/code>,
console<\/code> or
composer<\/code> could re-use.<\/p>\n\n
run<\/code> files that I use in my open-source code, you can look in my public GitHub repositories<\/a>, and for more information, here is Nick's blog post where I first found the idea<\/a>.<\/p>\n\n ",
"format": "full_html",
"processed": "\n
Makefile<\/code>.<\/p>\n\n
# Start the project.\nstart:\n docker-compose up -d\n\n# Stop the project.\nstop:\n docker-compose down\n\n# Run a Drush command.\ndrush:\n docker-compose exec php-fpm drush $(ARGS)\n<\/code><\/pre>\n\n
make start<\/code> to start the project, and
make stop<\/code> to stop it.<\/p>\n\n
drush<\/code> command, I'd have to type
ARGS=\"cache:rebuild\" make drush<\/code> for them to get added and the command to work as expected.<\/p>\n\n
What I'm using now<\/h2>\n\n
run<\/code> file, which is something that I learned from Nick Janetakis' blog and YouTube channel.<\/p>\n\n
.\/run test<\/code> or
.\/run composer require something<\/code>.<\/p>\n\n
run<\/code> script:<\/p>\n\n
#!\/usr\/bin\/env bash\n\nfunction help() {\n # Display some default help text.\n # See examples on GitHub of how to list the available tasks.\n}\n\nfunction start {\n # Start the project.\n docker-compose up -d\n}\n\nfunction stop {\n # Stop the project.\n docker-compose down\n}\n\nfunction drush {\n # Run a Drush command with any additional arguments.\n # e.g. \".\/run drush cache:rebuild\"\n docker-compose exec php-fpm drush \"${@}\"\n}\n\n# Execute the command, or run \"help\".\neval \"${@:-help}\"\n<\/code><\/pre>\n\n
$1<\/code>,
$2<\/code> etc to get specific arguments, or
$@<\/code> to get them all, so
.\/run drush cache:rebuild<\/code> works as expected and any additional arguments are included.<\/p>\n\n
test:unit<\/code> and
test:commit<\/code>, and tasks can run other tasks. I use this for running groups of commands within a CI pipeline, and to extract helper functions for tasks like running
docker-compose exec<\/code> within the PHP container that other commands like
drush<\/code>,
console<\/code> or
composer<\/code> could re-use.<\/p>\n\n
run<\/code> files that I use in my open-source code, you can look in my public GitHub repositories<\/a>, and for more information, here is Nick's blog post where I first found the idea<\/a>.<\/p>\n\n ",
"summary": null
}
],
"feeds_item": [
{
"imported": "2025-05-11T09:00:57+00:00",
"guid": null,
"hash": "15a1f14b232babef6136f4cc242315c0",
"target_type": "feeds_feed",
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
}
]
}