* Add stock quantity, datasheet URL, and HTTP caching to KiCad API - Add Stock field showing total available quantity across all part lots - Add Storage Location field when parts have stored locations - Resolve actual datasheet PDF from attachments (by type name, attachment name, or first PDF) instead of always linking to Part-DB page - Keep Part-DB page URL as separate "Part-DB URL" field - Add ETag and Cache-Control headers to all KiCad API endpoints - Support conditional requests (If-None-Match) returning 304 - Categories/part lists cached 5 min, part details cached 1 min * Add KiCadHelper unit tests and fix PDF detection for external URLs - Add comprehensive KiCadHelperTest with 14 test cases covering: - Stock quantity calculation (zero, single lot, multiple lots) - Stock exclusion of expired and unknown-quantity lots - Storage location display (present, absent, multiple) - Datasheet URL resolution by type name, attachment name, PDF extension - Datasheet fallback to Part-DB URL when no match - "Data sheet" (with space) name variant matching - Fix PDF extension detection for external attachments (getExtension() returns null for external-only attachments, now also parses URL path) * Fix 304 response body, parse_url safety, and location/stock consistency - Use empty Response instead of JsonResponse(null) for 304 Not Modified to avoid sending "null" as response body - Guard parse_url() result with is_string() since it can return false for malformed URLs - Move storage location tracking inside the availability check so expired and unknown-quantity lots don't contribute locations * Fix testPartDetailsPart2 to actually test Part 2 The test was requesting /parts/1.json instead of /parts/2.json and had Part 1's expected data. Now tests Part 2 which inherits EDA info from its category and footprint, verifying the inheritance behavior. * Use Symfony's built-in ETag handling for HTTP caching Replace manual If-None-Match comparison with Response::setEtag() and Response::isNotModified(), which properly handles ETag quoting, weak vs strong comparison, and 304 response cleanup. Fixes PHPStan return type error and CI test failures. * Add configurable KiCad field export for part parameters Add a kicad_export checkbox to parameters, allowing users to control which specifications appear as fields in the KiCad HTTP library API. Parameters with kicad_export enabled are included using their formatted value, without overwriting hardcoded fields like description or Stock. * Add partdb:kicad:populate command for bulk KiCad path assignment Console command that populates KiCad footprint/symbol paths on Footprint and Category entities based on name-to-library mappings. Supports dry-run, force overwrite, and list modes. Includes 130+ footprint mappings and 30+ category symbol mappings for KiCad 9.x standard libraries. * Add CSV import support for EDA/KiCad fields Add user-friendly column aliases (kicad_symbol, kicad_footprint, kicad_reference, kicad_value, eda_exclude_bom, etc.) to the CSV import system. Users can now bulk-set KiCad symbols, footprints, and other EDA metadata via CSV/Excel import without knowing the internal dot notation. * Add batch EDA field editing from parts table Users can now select multiple parts in any parts table and batch-edit their EDA/KiCad fields (symbol, footprint, reference prefix, value, visibility, exclude from BOM/board/sim). Each field has an "Apply" checkbox so users control exactly which fields are changed. * Remove unused counter variable in BatchEdaController * Fix PHPStan errors in PopulateKicadCommand and BatchEdaController Add @var type annotations for Doctrine repository findAll() calls so PHPStan can resolve getEdaInfo() on Footprint/Category entities. Fix array return type for numeric-string keys and add explicit callback to array_filter to satisfy strict rules. * Fix batch EDA edit: required validation and pre-populate shared values - Add required=false to TriStateCheckboxType fields so HTML5 validation doesn't force users to check visibility/BOM/board checkboxes - Pre-populate form fields when all selected parts share the same EDA value, so users can see current state before editing * Add KiCad API v2, orderdetail export control, EDA status indicator, BOM improvements - Add KiCad API v2 endpoints (/kicad-api/v2) with volatile field support for stock and storage location (shown but not saved to schematic) - Add kicad_export flag to Orderdetail entity for per-supplier SPN control (backward compatible: if no flag set, all SPNs exported as before) - Add EDA completeness indicator column in parts datatable (bolt icon) - Add ?minimal=true query param for faster category parts loading - Improve category descriptions (use comment instead of URL when available) - Improve BOM importer multi-footprint support: merge entries by Part-DB part ID when linked, tracking footprint variants in comments - Fix KiCost manf/manf# fields always present (not conditional on orderdetails) - Fix duplicate getEdaInfo() call in shouldPartBeVisible - Consolidate supplier SPN and KiCost field generation into single loop * Fix kicad_export column default for SQLite compatibility Add options default to ORM column definition so schema:update works correctly on SQLite test databases. * Make EDA status bolt icon clickable to open EDA settings tab * Fix EDA bolt link to correctly open EDA tab via data-turbo=false * Add configurable datasheet URL mode for KiCad API New setting "Datasheet field links to PDF" in KiCad EDA settings. When enabled (default), the datasheet field resolves to the actual PDF attachment URL. When disabled, it links to the Part-DB page (old behavior). Configurable via settings UI or EDA_KICAD_DATASHEET_AS_PDF env var. * Fix settings crash when upgrading: make datasheetAsPdf nullable The settings bundle stores values in the database. When upgrading from a version without datasheetAsPdf, the stored JSON lacks this key, causing a TypeError when assigning null to a non-nullable bool. Making it nullable with a fallback in KiCadHelper fixes the upgrade path. * Add functional tests for KiCad API v2 and batch EDA controller - KiCadApiV2ControllerTest: root, categories, parts, volatile fields, v1 vs v2 comparison, cache headers, 304 conditional request, auth - BatchEdaControllerTest: page load, empty redirect, form submission * Fix test failures: correct ids format and anonymous access assertion * Improve test coverage for BatchEdaController Add tests for: applying all EDA fields at once, custom redirect URL, and verifying unchecked fields are skipped. * Address PR review: rename to eda_visibility, merge migrations, API versioning Changes based on jbtronics' review of PR #1241: - Rename kicad_export -> eda_visibility (entities, forms, templates, translations, tests) with nullable bool for system default support - Merge two database migrations into one (Version20260211000000) - Rename createCachedJsonResponse -> createCacheableJsonResponse - Change bool $apiV2 -> int $apiVersion with version validation - EDA visibility field only shown for part parameters, not other entities - PopulateKicadCommand: check alternative names of footprints/categories - PopulateKicadCommand: support external JSON mapping file (--mapping-file) - Ship default mappings JSON at contrib/kicad-populate/default_mappings.json - Add system-wide defaultEdaVisibility setting in KiCadEDASettings - Add KiCad HTTP Library v2 spec link in controller docs * Fix duplicate loadMappingFile method causing PHP fatal error * Add tests for mapping file and alternative name matching, update populate command docs Add 5 new tests for PopulateKicadCommand covering: - Custom mapping file overriding defaults - Invalid JSON mapping file error handling - Missing mapping file error handling - Footprint alternative name matching - Category alternative name matching Update contrib README to document --mapping-file option, alternative name matching, and custom JSON mapping format. * Split out KiCad API v2 into separate PR as requested by maintainer Remove v2 controller, tests, and volatile field support from this PR. The v2 API will be submitted as a separate PR for focused discussion. * Improve test coverage for KiCadHelper and PopulateKicadCommand KiCadHelper: Add tests for orderdetail eda_visibility filtering, backward compatibility when no flags set, manufacturer/KiCost fields, and parameter with empty name skipping. PopulateKicadCommand: Add tests for mapping file with both footprints and categories sections, and mapping file with only categories. * Load populate Kicad default mappings from json file * Moved kicad:populate documentation to central docs * Added introduced column to PartTableColumns to make it configurable in the settings * Use TristateCheckboxes for parameter and orderdetail types * Fixed translation keys * Split up default eda visibility for parameters and purchase infos --------- Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
5.4 KiB
| title | layout | parent |
|---|---|---|
| Console commands | default | Usage |
Console commands
Part-DB provides some console commands to display various information or perform some tasks.
The commands are invoked from the main directory of Part-DB with the command php bin/console [command] in the context
of the web server user (so usually the webserver user), so you may have to use sudo or su to execute the commands:
sudo -u www-data php bin/console [command]
You can get help for every command with the parameter --help. See php bin/console for a list of all available
commands.
If you are running Part-DB in a Docker container, you must either execute the commands from a shell inside the container,
or use the docker exec command to execute the command directly inside the container. For example, if your Docker container
is named partdb, you can execute the command php bin/console cache:clear with the following command:
docker exec --user=www-data partdb php bin/console cache:clear
{: .warning }
If you run a root console inside the docker container, and wanna execute commands on the webserver behalf, be sure to use
sudo -Ecommand (with the-Eflag) to preserve env variables from the current shell. Otherwise Part-DB console might use the wrong configuration to execute commands.
Troubleshooting
User management commands
php bin/console partdb:users:list: List all users of this Part-DB instancephp bin/console partdb:users:set-password [username]: Set/Changes the password of the user with the given username. This allows administrators to reset a password of a user, if he forgot it.php bin/console partdb:users:enable [username]: Enable/Disable the user with the given username (use--disableto disable the user, which prevents login)php bin/console partdb:users:permissions: View/Change the permissions of the user with the given usernamephp bin/console partdb:users:upgrade-permissions-schema: Upgrade the permissions schema of users to the latest version (this is normally automatically done when the user visits a page)php bin/console partdb:logs:show: Show the most recent entries of the Part-DB event log / recent activityphp bin/console partdb:user:convert-to-saml-user: Convert a local user to a SAML/SSO user. This is needed, if you want to use SAML/SSO authentication for a user, which was created before you enabled SAML/SSO authentication.
Currency commands
php bin/console partdb:currencies:update-exchange-rates: Update the exchange rates of all currencies from the internet
Update Manager commands
{: .note }
The Update Manager is an experimental feature. See the Update Manager documentation for details.
php bin/console partdb:update: Check for and perform updates to Part-DB. Use--checkto only check for updates without installing.php bin/console partdb:maintenance-mode: Enable, disable, or check the status of maintenance mode. Use--enable,--disable, or--status.
Installation/Maintenance commands
php bin/console partdb:backup: Backup the database and the attachmentsphp bin/console partdb:version: Display the current version of Part-DB and the used PHP versionphp bin/console partdb:check-requirements: Check if the requirements for Part-DB are met (PHP version, PHP extensions, etc.) and make suggestions what could be improvedpartdb:migrations:convert-bbcode: Migrate the old BBCode markup codes used in legacy Part-DB versions (< 1.0.0) to the new Markdown syntaxpartdb:attachments:clean-unused: Remove all attachments which are not used by any database entry (e.g. orphaned attachments)partdb:cache:clear: Clears all caches, so the next page load will be slower, but the cache will be rebuilt. This can maybe fix some issues when the cache was corrupted. This command is also needed after changing things in theparameters.yamlfile or upgrading Part-DB.partdb:migrations:import-partkeepr: Imports a mysqldump XML dump of a PartKeepr database into Part-DB. This is only needed for users, which want to migrate from PartKeepr to Part-DB. All existing data in the Part-DB database is deleted!settings:migrate-env-to-settings: Migrate configuration from environment variables to the settings interface. The value of the environment variable is copied to the settings database, so the environment variable can be removed afterwards without losing the configuration.partdb:migrations:convert-db-platform: Convert the database platform (e.g. from SQLite to MySQL/MariaDB or PostgreSQL, or vice versa).
Database commands
php bin/console doctrine:migrations:migrate: Migrate the database to the latest versionphp bin/console doctrine:migrations:up-to-date: Check if the database is up-to-date
Attachment commands
php bin/console partdb:attachments:download: Download all attachments that are not already downloaded to the local filesystem. This is useful to create local backups of the attachments, no matter what happens on the remote, and also makes picture thumbnails available for the frontend for them.
EDA integration commands
php bin/console partdb:kicad:populate: Populate KiCad footprint paths and symbol paths for footprints and categories based on their names. Use--dry-runto preview changes without applying them, and--listto list current values. See the EDA integration documentation for more details.