-
Notifications
You must be signed in to change notification settings - Fork 2
ConventionsBestPractices
The conventions outlined here are in place to promote consistency, increase application development, and allow the framework to make certain assumptions about your application. It's recommended that you follow the guidelines listed here.
Autoloading should be done using PSR-4 and composer. PSR-0 is still perfectly valid but it's outdated by the newer PSR-4. The framework itself will not support installation through any means other than composer.
Any Symfony command located in package_name/src/Console
will be automatically loaded and added to the console script.
If you plan on distributing your packages please remember that your packages should come out of the box with sane defaults and be easy for the user to setup. If applicable, remove any rapid development code and replace them with their most performant counterparts. Generally this means replacing service annotations or array configurations with service factories.
100% test coverage is encouraged! This gives both you and your users assurances when using your product.
Packages are named by stripping the vendor and package from the file, lower-casing the result, and then replacing \
with .
.
- Spiffy\AsseticPackage -> assetic
- Spiffy\DBALPackage -> dbal
- Spiffy\DoctrineORMPackage -> doctrine.orm
These names are primarily used to determine the configuration that goes with each package.
All package configuration should be under the package name (as given above) and use all lower-case with underscore separation.
Tests should be placed in the package_name/test
folder and should not be namespaced with Test. PHPUnit already enforces the Test
suffix on classes which will remove any naming collisions.
Using annotations to build services is great and is encouraged for application code. Code that is intended to be distributed as a package should never use annotations and should always use service factories. Service factories are the most performant way to create services and provides no development performance hit for the end-user. All SpiffyFramework packages should be written with performance and ease-of-use for the end-user in mind. Remember this when writing packages meant for distribution!
© 2014 Kyle Spraggs