S
S
Sergey Burduzha2021-12-27 19:37:26
GNU Make
Sergey Burduzha, 2021-12-27 19:37:26

How to set dynamic parameters in Makefile?

Good afternoon.
In laraever, you can run commands through the Makefile if you work with docker.
I already set up some commands, but how to add dynamic commands.
Let's say the command:

docker-container exec php php artisan make:seed UserSeeder -> make seed UserSeeder


Here are my commands

up:
  sudo docker-compose up -d

down:
  sudo docker-compose down

down-orphan:
  sudo docker-compose down --remove-orphans

build:
  sudo docker-compose build

ps:
  sudo docker-compose ps

list:
  sudo docker-compose exec php-fpm php artisan route:list -c --name=users

migrate:
  docker-compose exec php-fpm php artisan migrate

clear:
  docker-compose exec php-fpm php artisan view:clear
  docker-compose exec php-fpm php artisan cache:clear
  docker-compose exec php-fpm php artisan config:clear
  docker-compose exec php-fpm php artisan route:clear

seed:
  docker-compose exec php-fpm php artisan db:seed

make-seed:
  docker-compose exec php-fpm php artisan make:seeder UsersTableSeeder

tinker:
  docker-compose exec php-fpm php artisan tinker

ide-generate:
  php artisan ide-helper:generate

install:
  docker-compose exec node npm install
prod:
  docker-compose exec node npm run prod
dev:
  docker-compose exec node npm run dev
watch:
  docker-compose exec node npm mix watch

perm:
  sudo chown ${USER}:${USER} bootstrap/cache -R
  sudo chown ${USER}:${USER} storage -R

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-12-27
@serii81

make takes a list of individual build targets, you can't pass multiple words as an option. You can pass define with -D, for example:
make -DARGS="UserSeeder" seed
In the Makefile:

seed:
  docker-container exec php php artisan make:seed $(ARGS)

But in general, it's easier to write your own script than to fight the limitations of make.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question