phpink / nami-core-bundle
Nami CMS - CORE Bundle
Installs: 11
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5.9
- doctrine/doctrine-bundle: ^1.6
- friendsofsymfony/http-cache-bundle: 2.0.*@dev
- friendsofsymfony/rest-bundle: ^2.1
- gedmo/doctrine-extensions: 3.0.x
- gfreeau/get-jwt-bundle: 2.0.*@dev
- incenteev/composer-parameter-handler: ^2.0
- jms/serializer-bundle: ^1.1
- knplabs/knp-menu-bundle: ^2.0
- lexik/jwt-authentication-bundle: 2.0.*@dev
- liip/imagine-bundle: ~1.0
- nelmio/api-doc-bundle: ^2.4
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/assetic-bundle: ~2.7
- symfony/monolog-bundle: ^2.8
- symfony/swiftmailer-bundle: ^2.3
- symfony/symfony: 3.0.5
- twig/extensions: 1.1.0
- willdurand/hateoas-bundle: ^1.0
Requires (Dev)
- doctrine/mongodb-odm-bundle: ^3.1
- doctrine/orm: ^2.5
- liip/functional-test-bundle: 1.6.x
- sensio/generator-bundle: ^3.0
- symfony/phpunit-bridge: ^3.0
Suggests
- symfony/nami-admin-bundle: For the back section of your application
This package is not auto-updated.
Last update: 2025-01-18 20:46:39 UTC
README
Welcome to the NamiCoreBundle repository - a Symfony 2.7 bundle.
PhpInk\Nami\CoreBundle is the main bundle of a Nami CMS application. It contains the dependencies configuration, Doctrine ORM/ODM mapping and FOSRest controllers to provide an API.
- Installation
Getting started
Run the following command to install the bundle :
composer require phpink/nami-core-bundle
To get NAMI working with MongoDB, after specifying the configuration driver to ''odm''' instead of '''orm''', add the following line to your composer.json :
"doctrine/mongodb-odm-bundle": "3.0.*@dev",
Then, add the following line to your AppKernel.php :
new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
Generate new RSA keys [optional]
Run the following OpenSSL commands to generate RSA keys for JSON Web Token authentication :
openssl genrsa -out app/var/jwt/private.pem -aes256 4096
openssl rsa -pubout -in app/var/jwt/private.pem -out app/var/jwt/public.pem
- API endpoints
All available endpoints are available in a Postman dump
nami.postman_collection
Some http client you can run to test the API :
GET http://host/api-doc/ REST API documentation [HTML]
GET http://host/api/ REST API ping [JSON]
POST http://host/api/token API token getter [JSON]
GET http://host/api/pages API get all method [JSON]
GET http://host/api/pages/1 API get one method [JSON]
POST http://host/api/pages/1 API update one method [JSON]
DELETE http://host/api/pages/1 API delete one method [JSON]
What's inside?
The bundle is configured with the following defaults:
-
Twig is the only configured template engine;
-
Translations are activated
-
Doctrine ORM/DBAL or Doctrine MongoDB is configured;
-
Swiftmailer is configured;
-
Annotations for everything are enabled.
It comes pre-configured with the following bundles:
-
FrameworkBundle - The core Symfony framework bundle
-
SensioFrameworkExtraBundle - Adds several enhancements, including template and routing annotation capability
-
DoctrineBundle - Adds support for the Doctrine ORM
-
DoctrineMongoDBBundle - Adds support for the Doctrine ODM
-
DoctrineExtensions - Doctrine2 behavioral extensions
-
DoctrineFixtures (in dev/test env) - Load data fixtures into the Doctrine ORM
-
TwigBundle - Adds support for the Twig templating engine
-
SecurityBundle - Adds security by integrating Symfony's security component
-
SwiftmailerBundle - Adds support for Swiftmailer, a library for sending emails
-
MonologBundle - Adds support for Monolog, a logging library
-
AsseticBundle - Adds support for Assetic, an asset processing library
-
WebProfilerBundle (in dev/test env) - Adds profiling functionality and the web debug toolbar
-
SensioDistributionBundle (in dev/test env) - Adds functionality for configuring and working with Symfony distributions
-
SensioGeneratorBundle (in dev/test env) - Adds code generation capabilities
-
FOSRestBundle - Adds rest functionality
-
FOSHttpCacheBundle - This bundle offers tools to improve HTTP caching with Symfony2
-
NelmioApiDocBundle - Add API documentation features
-
BazingaHateoasBundle - Adds HATEOAS support
-
HautelookTemplatedUriBundle - Adds Templated URIs (RFC 6570) support
-
LexikJWTAuthenticationBundle - JSON Web Token generation
-
GfreeauGetJWTBundle - JSON Web Token authentication
-
LiipImagineBundle - Image thumbnail generation
Enjoy!
API inner working
Controllers
CoreBundle controllers extend a base AbstractController
, which contains a set of methods for the Doctrine CRUD worflow.
Associated Doctrine model/repository & FormType class names are guessed automatically.
For example: NamiCoreBundle:Model\Orm\User
entity & NamiCoreBundle:Form\UserType
for NamiCoreBundle:Controller\UserController
.
The doctrine repository used by the controller to run the generic CRUD commands is the one associated by default to the model. A different one can be called :
public function getEntitiesAction() { $productRepo = $this->getRepository('Product'); // From model name // or $productRepo = $this->getRepository('\PhpInk\Nami\CoreBundle\Model\Orm\Products'); // More specific ... return $this->restView(...); // Returns a JSON response }
Repositories
Core repositories extend a base AbstractRepository
, which contains all the CRUD methods called from controllers.
Repositories can overload the base properties, such as orderByFields
, filterByFields
.
They must implement a buildItemsQuery
method that will be called to create the Doctrine QueryBuilder retrieving one or more item from the database.
As for creation & update, the controllers instantiate the form type related to the associated model.
Json TO Forms
A JsonDecoder is implemented and modifies the input request data.
It is called from the FosRest body listener (configuration is in
src/PhpInk/CoreBundle/DependencyInjection/NamiCoreBundleExtension.php
).
It transforms json input booleans true,false
into optional 0,1
checkboxes for FormTypes.
To execute specific code after an item creation or update, take a look at the UserController::onPostSave
method that sends the user confirmation mail.