You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e1d07bc
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: general/development/tools/composer.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,3 +47,75 @@ As far as there are a number of variables affecting how that lock file will be g
47
47
1. Check that the `composer.lock` file, together with other changes, does include the changes you've performed in the `composer.json` file.
48
48
1. Ideally, run both phpunit and behat tests and verify that there isn't any problem, using all the supported PHP versions.
49
49
1. Done, you can send the changes for review, integration and, if everything goes ok, will be applied upstream without problem.
50
+
51
+
## Runtime status checks {/* #runtime-status-checks */}
52
+
53
+
<Sinceversion="5.3"issueNumber="MDL-88576" />
54
+
55
+
Moodle provides a Composer runtime status API for inspecting the state of Composer-managed dependencies.
56
+
57
+
The API can be used to:
58
+
59
+
- Check whether Composer dependencies are installed.
60
+
- Verify that installed package versions match those recorded in `composer.lock`.
61
+
- Identify missing packages.
62
+
- Identify outdated packages.
63
+
64
+
### Obtaining the service {/* #obtaining-the-service */}
65
+
66
+
The Composer service must be obtained through Moodle's dependency injection container.
67
+
68
+
```php
69
+
$composer = \core\di::get(\core\composer::class);
70
+
```
71
+
72
+
### Checking Composer installation status {/* #checking-composer-installation-status */}
73
+
74
+
To determine whether Composer dependencies are installed:
75
+
76
+
```php
77
+
if ($composer->is_installed()) {
78
+
echo 'Composer dependencies are installed.';
79
+
}
80
+
```
81
+
82
+
### Retrieving overall status {/* #retrieving-overall-status */}
83
+
84
+
The `get_status()` method returns a `\core\composer\status` object containing the overall Composer runtime status and the status of all packages defined in `composer.lock`.
85
+
86
+
```php
87
+
$status = $composer->get_status();
88
+
89
+
if (!$status->installed) {
90
+
echo 'Composer dependencies are not installed.';
91
+
} else if (!$status->current) {
92
+
echo 'One or more Composer packages require attention.';
93
+
}
94
+
```
95
+
96
+
The status object also provides convenience methods for identifying packages in a particular state:
97
+
98
+
```php
99
+
$current = $status->current_packages();
100
+
$missing = $status->missing_packages();
101
+
$outdated = $status->outdated_packages();
102
+
```
103
+
104
+
### Checking a specific package {/* #checking-a-specific-package */}
105
+
106
+
The `get_package_status()` method returns a `\core\composer\package_status` object containing information about the package's installation state and version information.
0 commit comments