ebitkov/app-lock-composer-plugin
Composer plugin for Laravel/PHP apps that marks the application as “updating” while Composer runs, helping prevent access or inconsistent state during dependency updates.
Installation
Add the plugin to your project’s composer.json under config.extra.plugins:
{
"config": {
"extra": {
"plugins": {
"ebitkov/app-lock-composer-plugin": {
"enabled": true
}
}
}
}
}
Then run:
composer require ebitkov/app-lock-composer-plugin --dev
First Use Case After installation, the plugin will automatically:
.composer/app-lock file when running composer update or composer install.composer.lock unless the .composer/app-lock file is removed.Verify it works:
composer update
# Check if `.composer/app-lock` exists
ls -la .composer/
Team Collaboration
.composer/app-lock as a team agreement to avoid accidental composer.lock modifications..composer/app-lock to .gitignore if you want to enforce lock consistency only locally.CI/CD Pipelines
.composer/app-lock presence before allowing composer.lock changes.
# Example Git hook (pre-commit)
if [ -f ".composer/app-lock" ] && ! git diff --name-only HEAD | grep -q "composer.lock"; then
echo "✅ Lockfile unchanged or intentionally updated."
else
echo "❌ composer.lock modified without app-lock. Aborting."
exit 1
fi
composer.lock is modified without .composer/app-lock:
if [ -f ".composer/app-lock" ] && ! git diff --name-only origin/main composer.lock > /dev/null; then
echo "::error::composer.lock was modified without app-lock. Remove .composer/app-lock to allow changes."
exit 1
fi
Local Development
.composer/app-lock to allow composer.lock edits (e.g., for dependency tweaks):
rm .composer/app-lock
composer update package-name
# Re-enable later
touch .composer/app-lock
Custom Scripts
package.json or composer.json to toggle the lock:
{
"scripts": {
"lock:allow": "rm -f .composer/app-lock",
"lock:enforce": "touch .composer/app-lock"
}
}
False Positives
composer.lock modifications when .composer/app-lock exists..composer/app-lock and then run composer update, the plugin won’t block future composer.lock changes unless you recreate the file..composer/app-lock after intentional updates to re-enforce protection.Merge Conflicts
.composer/app-lock is committed to version control, merging branches may cause conflicts..gitignore) and regenerate it locally as needed.Composer Version Compatibility
composer update --dry-run
Overriding Default Behavior
composer install or composer update—it only prevents manual composer.lock edits.Plugin Not Triggering
composer.json:
"extra": {
"plugins": {
"ebitkov/app-lock-composer-plugin": { "enabled": true }
}
}
-vvv to see plugin logs:
composer update -vvv
Permission Issues
.composer/app-lock can’t be created, check directory permissions:
mkdir -p .composer && chmod -R 777 .composer
Composer Version Conflicts
composer require ebitkov/app-lock-composer-plugin:^1.0.1 --dev
Custom Lock Files
.composer/app-lock by default. To change the filename:
src/AppLockPlugin.php (line ~30).getLockFilePath() method.Integrate with Other Tools
pre-commit tools like Husky or pre-commit to enforce lock rules.// app/Console/Commands/ToggleAppLock.php
public function handle() {
$lockFile = base_path('.composer/app-lock');
if (file_exists($lockFile)) {
unlink($lockFile);
$this->info('App lock removed. composer.lock can now be modified.');
} else {
file_put_contents($lockFile, '');
$this->info('App lock enforced. composer.lock changes will be blocked.');
}
}
Visual Feedback
.gitattributes rule to highlight the lock file:
.composer/app-lock diff=composerlock
diff driver in .git/config for better visibility in Git clients.How can I help you explore Laravel packages today?