pixiekat/symfony-bootstrap

There is no license information available for the latest version (1.0.6) of this package.

A small library to create and bootstrap an application using Symfony components.

1.0.6 2025-04-13 19:54 UTC

This package is auto-updated.

Last update: 2025-04-13 22:34:12 UTC


README

This is a basic library which bootstraps an application using Symfony Components.

Installation

composer require pixiekat\symfony-bootstrap:^1.0 or view the releases page on Codeberg.

Usage

Define your routes for your application.

use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '/foo', name: 'foo', methods: ['GET'])]

Then create the application.

try {
  $app = (new \Pixiekat\SymfonyBootstrap\Bootstrap)->createApplication('dev');
  $response = $app->getResponse(['error_pages_dir' => '/errors']) ;
  $response->send();
}
catch (Exception $e) {
  throw \Exception('Could not bootstrap.');
}

Pull services from the container with $app->getContainer().

Services

You can define services within <root>/config/services.yml. The Application class will read them in when bootstrapping.

services:

  last_fm_client:
    class: Barryvanveen\Lastfm\Lastfm
    arguments:
      - '@http.client'
      - '%env(LAST_FM_API_KEY)%'

  app_last_fm_manager:
    class: App\Service\LastFmManager
    arguments:
      - '%env(LAST_FM_API_KEY)%'
      - '%env(LAST_FM_USER)%'
      - '@cache.app'
      - '@logger'
      - '@last_fm_client'

  app.twig.last_fm_now_playing_extension:
    class: App\Twig\LastFmNowPlayingExtension
    arguments:
      - '@app_last_fm_manager'
      - '@app.cache'
      - '@request'
      - '@logger'
    tags:
      - { name: twig.extension }

Doctrine

Doctrine is available as doctrine.orm.entity_manager or using $app->getDoctrine().

Add your DB connection string as environment variable DATABASE_URL.

Add your migrations.yml to <root>/config/.

table_storage:
  table_name: doctrine_migration_versions
  version_column_name: version
  version_column_length: 191
  executed_at_column_name: executed_at
  execution_time_column_name: execution_time

migrations_paths:
  'App\Migrations': ./../migrations

all_or_nothing: true
transactional: true
check_database_platform: true
organize_migrations: none

connection: null
em: null

Add your Entities to <root>/src/Entity.

Add your Repositories to <root>/src/Repository.

Caveats

This is a very rudimentary project mostly designed for me that's a proof of concept in constant development but feel free to request anything or pull request. :)

License

Anyway this project is licensed under the Anti-Capitalist Software License so basically I don't care if you use this as long as you're not in law enforcement, immigration enforcement, or the military. I am 100% against AI and LLMs, so don't use this package with any combination of those two things either.

Free Palestine. Human beings aren't illegal. Fuck borders.

Contact Me

You can find me on Bluesky mostly. I don't bite. <3