Common part of Flextype is a Flextype Core Class that extends Slim Framework that we are using under the hood. Slim is amazing PHP micro framework that helps quickly write simple yet powerful web applications and APIs.

Slim Framework Resources

Getting back to Flextype Core.

With help of Flextype Core Class we are able to access all features and develop a new amazing features for Flextype powered project.

Methods

Method Description
getInstance Get the available Flextype Application instance.
getVersion Get current Flextype version.
container Get and Set Dependency Injection Container.

Methods Details

getInstance

Get the available Flextype Application instance.

/**
 * Returns Flextype Instance
 *
 * @param ContainerInterface|array $container Container.
 */
public static function getInstance($container = []): Flextype

Examples

$instance = Flextype::getInstance();
getVersion

Get current Flextype version.

/**
 * Returns the current Flextype version
 */
public function getVersion(): string

Examples

$version = Flextype::getInstance()->getVersion();
container

Get and Set Dependency Injection Container.

/**
 * Get/Set Dependency Injection Container.
 *
 * @param string|null $name DI Container name.
 */
public function container(?string $name = null)

Examples

// Get container object.
$container = Flextype::getInstance()->container();

// Set new container.
Flextype::getInstance()->container()['name'] = function () {
    return new ServiceName();
};

// Get specific container object by name.
$entries = Flextype::getInstance()->container('entries');

We recommend to use our flextype helper function to access all Flexype Application methods, set and get containers.

Examples

// Get the available Flextype Application instance.
$instance = flextype();

// Get current Flextype version.
$version = flextype()->getVersion();

// Get container object.
$container = flextype()->container();

// Set new container.
flextype()->container()['name'] = function () {
    return new ServiceName();
};

// Get specific container object by name
$entries = flextype()->container('entries');

// ... or even better :)
$entries = flextype('entries');

With flextype helper function you can access Flexype Application and all available Slim Framework methods.

Examples

// Add new GET route.
flextype()
  ->get('/dashboard', 'DashboardController:index')
  ->setName('admin.dashboard.index');

// Add new POST route.
flextype()
  ->get('/save-form', 'CustomServiceController:saveForm')
  ->setName('service.form.index');

Check all available methods: slimframework.com/docs/v3/

Services

List of available registered services in Flextype Dependency Injection Container.

Name Links
session documentation
registry documentation
logger documentation
emitter documentation
slugify documentation
cache documentation
parsers documentation
serializers documentation
images documentation
entries documentation
media documentation
plugins documentation
cors documentation

On This Page