webservco / component-common
Common dependencies for component projects.
Package info
github.com/webservco/component-common
Language:Dockerfile
pkg:composer/webservco/component-common
Requires
- php: ^8.4
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Common dependencies for component projects. It holds the shared PHP_CodeSniffer ruleset (.phpcs/php-coding-standard.xml, which extends webservco/coding-standards with the component namespaces) and the Docker configuration.
Component workflow
Create project repository
- public
- leave every other option unchecked (no README, license or
.gitignore). The repository has to start empty.
Set up project name
COMPONENT_NAME='COMPONENT_NAME';
Run customization commands (clone component-skeleton)
cd ~/p/webservco-components && \ git clone git@github.com:webservco/component-skeleton.git $COMPONENT_NAME && \ cd $COMPONENT_NAME && \ git remote set-url origin git@github.com:webservco/$COMPONENT_NAME.git && \ sed -i -e "s|component-skeleton|$COMPONENT_NAME|g" README.md && \ sed -i -e "s|\"name\" : \"webservco/component-skeleton\"|\"name\" : \"webservco/$COMPONENT_NAME\"|g" composer.json && \ sed -i -e "s|name: component-skeleton|name: $COMPONENT_NAME|g" .ddev/config.yaml && \ git add README.md composer.json .ddev/config.yaml && \ git commit -m 'Customize' && \ git push -u origin main
The skeleton already contains every directory the checks expect (bin, config, docs, public, resources, src/WebServCo, tests/Unit/WebServCo), each kept in git by an empty .gitkeep.
Add code
- Code goes in
src/WebServCo/(namespaceWebServCo\), unit tests intests/Unit/(namespaceTests\Unit\). - Delete a directory's
.gitkeeponce it holds real files. - Fill in the README template. The hidden comment at the top of the file explains how; delete it and the template note when done.
- Set
descriptionincomposer.jsonto the README description ("A PHP component/library." plus one sentence).
Development
# Start project. ddev start # Install dependencies. ddev c u # Run all validations. ddev c c # Run unit tests. ddev c test:dox
Without ddev (Docker)
Use this only when you can't set up a local environment. Working through Docker this way is more cumbersome.
# Customize DOCKER_IMAGE_TAG="webservco-component-${COMPONENT_NAME}"; DOCKER_CONTAINER_NAME="webservco-component-${COMPONENT_NAME}-container"; # Download Docker configuration curl -sL https://github.com/webservco/component-common/archive/refs/heads/main.tar.gz \ | tar xz --strip-components=1 component-common-main/.docker # Build and run docker build --tag ${DOCKER_IMAGE_TAG} -f .docker/config/php84-cli-copy/Dockerfile . docker run -it --rm --name ${DOCKER_CONTAINER_NAME} ${DOCKER_IMAGE_TAG} /bin/bash -c "composer check:phpcs" # Cleanup docker image rm ${DOCKER_IMAGE_TAG}
Add dependencies
Publish tag
git tag vX.Y.Z && git push --tags
Publish on packagist
Update index
Index
Misc
- webservco/coding-standards (Coding standards, dev dependency)
- webservco/component-common (Common dependencies)
- webservco/component-skeleton (Project template, not on packagist)
- webservco/http-client-test (test for http-client, not on packagist)
Components
- webservco/application
- webservco/application-default
- webservco/application-runner
- webservco/command
- webservco/configuration
- webservco/configuration-legacy
- webservco/controller
- webservco/data
- webservco/database
- webservco/database-legacy
- webservco/dependency-container
- webservco/document-object-model
- webservco/emitter
- webservco/environment
- webservco/error
- webservco/exception
- webservco/file
- webservco/form
- webservco/http
- webservco/http-client
- webservco/http-request-handler
- webservco/http-request-service
- webservco/http-response-service
- webservco/jsonapi
- webservco/jsonapi-application
- webservco/jwt
- webservco/log
- webservco/mail
- webservco/memory
- webservco/middleware
- webservco/paypal
- webservco/reflection
- webservco/route
- webservco/session
- webservco/stopwatch
- webservco/view