Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Framework Standard Edition Laravel Package

symfony/framework-standard-edition

Symfony Standard Edition: a full Symfony 3.4 application skeleton with AppBundle, Twig, Doctrine ORM/DBAL, Security, Swiftmailer, Monolog, and dev tools like Web Profiler and generators. Note: not compatible with Symfony 4+.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation:

    composer create-project symfony/framework-standard-edition my_project
    cd my_project
    
  2. First Use Case:

    • Create a Controller:

      php bin/console generate:controller HomePage
      

      This generates a basic controller (src/AppBundle/Controller/HomePageController.php) with a index action and Twig template (templates/home_page/index.html.twig).

    • Run the Dev Server:

      php bin/console server:run
      

      Visit http://localhost:8000/home-page to see the generated page.

  3. Key Files to Explore:

    • config/packages/ – Bundle configurations (e.g., doctrine.yaml, twig.yaml).
    • src/AppBundle/ – Default bundle for custom logic (controllers, entities, services).
    • templates/ – Twig templates for views.
    • var/log/ – Monolog logs for debugging.

Implementation Patterns

Core Workflows

  1. Routing and Controllers:

    • Use annotations (e.g., @Route) or YAML/XML/PHP routing (config/routes.yaml).
      // src/AppBundle/Controller/DefaultController.php
      namespace AppBundle\Controller;
      use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
      use Symfony\Component\HttpFoundation\Response;
      
      class DefaultController extends Controller
      {
          /**
           * @Route("/hello/{name}", name="greet")
           */
          public function index($name)
          {
              return new Response('<html><body>Hello '.$name.'</body></html>');
          }
      }
      
    • Best Practice: Group related routes in a single controller or use route collections for modularity.
  2. Database and Doctrine:

    • Define entities in src/AppBundle/Entity/ (e.g., User.php).
      // src/AppBundle/Entity/User.php
      namespace AppBundle\Entity;
      use Doctrine\ORM\Mapping as ORM;
      
      /** @ORM\Entity */
      class User
      {
          /** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
          private $id;
      
          /** @ORM\Column(type="string", length=50) */
          private $name;
      }
      
    • Generate migrations and update the schema:
      php bin/console doctrine:generate:entities AppBundle
      php bin/console doctrine:migrations:diff
      php bin/console doctrine:migrations:migrate
      
  3. Templating with Twig:

    • Extend base templates (templates/base.html.twig) and reuse blocks.
      {# templates/home_page/index.html.twig #}
      {% extends 'base.html.twig' %}
      {% block body %}
          <h1>Welcome, {{ app.user.name }}!</h1>
      {% endblock %}
      
    • Best Practice: Use Twig’s {% include %} for modular templates (e.g., headers, footers).
  4. Services and Dependency Injection:

    • Define services in config/services.yaml or as class annotations.
      # config/services.yaml
      services:
          AppBundle\Service\ExampleService:
              arguments: ['@doctrine.orm.entity_manager']
      
    • Inject services into controllers:
      public function __construct(ExampleService $exampleService) {
          $this->exampleService = $exampleService;
      }
      
  5. Security:

    • Configure firewall in config/packages/security.yaml:
      security:
          firewalls:
              main:
                  anonymous: ~
                  form_login:
                      login_path: login
                      check_path: login_check
      
    • Protect routes with annotations:
      use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
      
      /**
       * @Route("/admin", name="admin")
       * @Security("is_granted('ROLE_ADMIN')")
       */
      public function admin()
      {
          // ...
      }
      
  6. Logging and Debugging:

    • Use Monolog for structured logging:
      $this->get('logger')->info('User logged in', ['user_id' => $user->getId()]);
      
    • Leverage the Web Profiler (/_profiler/) in dev mode for request debugging.
  7. Email with Swiftmailer:

    • Send emails via Twig templates:
      $message = (new \Swift_Message('Hello'))
          ->setFrom('sender@example.com')
          ->setTo('recipient@example.com')
          ->setBody($this->renderView('emails/hello.html.twig', ['name' => 'John']), 'text/html');
      $this->get('mailer')->send($message);
      

Integration Tips

  1. Environment-Specific Configs:

    • Override configurations per environment (e.g., config/packages/dev/monolog.yaml).
    • Use %kernel.environment% in configs to switch behaviors.
  2. Asset Management:

    • Use Symfony’s assets component or bundles like symfony/webpack-encore-bundle for frontend assets.
  3. Testing:

    • Write functional tests in tests/Functional/ and unit tests in tests/Unit/.
    • Use php bin/console debug:router to validate routes in tests.
  4. Custom Bundles:

    • Create bundles for reusable logic (e.g., src/MyCustomBundle/).
    • Register bundles in config/bundles.php:
      return [
          // ...
          MyCustomBundle::class => ['all' => true],
      ];
      

Gotchas and Tips

Pitfalls

  1. Deprecation Warnings:

    • Symfony 3.4 is end-of-life (no longer maintained). Avoid using this package for new projects; migrate to Symfony 5/6 or Flex-based setups.
    • Example: SensioFrameworkExtraBundle is deprecated in favor of Symfony’s built-in annotations.
  2. Doctrine Common Issues:

    • Schema Migrations: Always run doctrine:migrations:diff after entity changes, then migrate.
    • Lazy Loading: Avoid N+1 queries by using ->get() or ->find() with eager-loading:
      $users = $entityManager->getRepository(User::class)->findAll();
      foreach ($users as $user) {
          $user->getPosts()->count(); // Avoids lazy-loading issues
      }
      
  3. Routing Conflicts:

    • Ensure route paths are unique. Use name attributes for reverse routing:
      $this->generateUrl('greet', ['name' => 'John']);
      
  4. Twig Auto-Reloading:

    • Clear the cache after template changes:
      php bin/console cache:clear
      
  5. Security Misconfigurations:

    • CSRF Protection: Enable it globally in security.yaml:
      security:
          csrf_protection:
              enabled: true
      
    • Sensitive Data: Never log passwords or tokens. Use masking in Monolog:
      monolog:
          handlers:
              main:
                  processor: monolog.processor.mask_sensitive_information
      
  6. Performance in Dev Mode:

    • Disable debug mode in production (APP_ENV=prod).
    • Use --no-debug flag for faster CLI commands:
      php bin/console doctrine:schema:update --no-debug
      

Debugging Tips

  1. Web Profiler:

    • Access _profiler/ in dev mode for request/response details, SQL queries, and exceptions.
    • Use the VarDumper component for debugging:
      use Symfony\Component\VarDumper\Cloner\VarCloner;
      use Symfony\Component\VarDumper\Dumper\HtmlDumper;
      
      $dumper = new HtmlDumper();
      $dumper->dump(new VarCloner(), $variable);
      
  2. Logging Levels:

    • Adjust log levels in config/packages/monolog.yaml:
      monolog:
          handlers:
              main:
                  level: debug # or info, warning, error
      
  3. Command-Line Debugging:

    • Use --env=dev to enable debug mode for CLI commands:
      php bin/console doctrine:query --env=dev
      
  4. Common Errors:

    • "Class Not Found": Clear the cache (cache:clear) or check autoloading (composer dump-autoload).
    • Database Connection Issues: Verify .env (e.g., DATABASE_URL) and permissions.

Extension Points

  1. Custom Console Commands:
    • Create commands in src/AppBundle/Command/:
      namespace AppBundle\Command;
      use Symfony\Component\Console
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope