I'm creating an app in Symfony which is using a library I'm writing at the same time.
While my application is being built with symfony, I want the component library to be completely framework independent as it needs to be reusable by applications not necessarily written in symfony.
Therefore I have a symfony bundle which integrates the library (the component)
The folder structure is a follows
src/MyVendor/
|-- Bundle
| `-- MyComponentBundle
| |-- Controller
| |-- DependencyInjection
| |-- Resources
| | |-- config
| | `-- views
| | `-- Default
| |-- Tests
| `-- Controller
| `-- MyObjectControllerTest.php
| `-- MyComponentBundle.php
`-- Component
`-- MyComponent
|-- doc
|-- src
`-- MyObject.php
|-- test
`-- MyObjectTest.php
|-- .gitignore
|-- composer.json
|-- LICENSE
|-- README.md
`-- phpunit.xml.dist
Questions:
Is MyComponent directory structure correct as per the PSR-x Autoloading standards? For example, how do I use MyObject from the library inside the bundle, i.e. in MyObjectControllerTest.php
Can MyObject reside in the namespace of MyVendor\MyComponent? If not, how do I have to amend the directory structure so that (1) I can use that namespace, and (2) so that it can be autoloaded inside MyObjectControllerTest.php, i.e. new MyVendor\MyComponent\MyObject(); will work; right now I'm getting PHP Fatal error: Class 'MyVendor\MyComponent\MyObject' not found in ...
Could you please direct me to an online resource to help me to publish MyComponent on github and make it available to symfony (I'm guessing most of that involves just setting up composer.json correctly)
Thank you
composer.json (or copy/past and edit some side one), submit your package on packagist (just insert github project link)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With