Installation
Run composer require dywee/blog-bundle in your Laravel project (note: this is a Symfony bundle, so ensure compatibility with Laravel via Symfony Bridge or use in a Symfony project).
Add the bundle to config/app.php under providers:
Dywee\BlogBundle\DyweeBlogBundle::class,
Routing
Add the routing to routes/web.php:
use Dywee\BlogBundle\Resources\config\routing.yml;
$loader = new \Symfony\Component\Config\Loader\LoaderInterface();
$loader->load(__DIR__.'/vendor/dywee/blog-bundle/Resources/config/routing.yml');
Note: Laravel’s native YAML routing support is limited; use a Symfony-compatible router or convert to PHP routes.
First Use Case
Create a blog post via the admin interface (if DyweeCoreBundle is integrated) or manually via:
use Dywee\BlogBundle\Entity\Post;
$post = new Post();
$post->setTitle('Hello World');
$post->setContent('First blog post!');
$em = $this->getDoctrine()->getManager();
$em->persist($post);
$em->flush();
Entity Management
Dywee\BlogBundle\Entity\Post for custom fields (e.g., slug, publishedAt).
namespace App\Entity;
use Dywee\BlogBundle\Entity\Post as BasePost;
class Post extends BasePost {
// Custom fields/methods
}
Dywee\BlogBundle\Entity\Category and Tag entities for taxonomy.Admin Integration
DyweeCoreBundle for CRUD interfaces (if available). Example:
// Configure admin routes in DyweeCoreBundle
$builder->root()->add('posts', 'dywee_blog_post_crud');
Frontend Display
$posts = $this->getDoctrine()->getRepository(Post::class)->findBy(['published' => true]);
{% for post in posts %}
<h2>{{ post.title }}</h2>
<p>{{ post.content|truncate(200) }}</p>
{% endfor %}
API Endpoints
Route::get('/api/posts', [PostController::class, 'index']);
Serializer (Symfony) or Laravel’s Resource classes.config/packages/doctrine.yaml includes:
orm:
mappings:
dywee_blog:
type: attribute
dir: "%kernel.project_dir%/vendor/dywee/blog-bundle/Entity"
prefix: "Dywee\BlogBundle\Entity"
alias: DyweeBlog
SymfonyBridge to integrate Symfony bundles:
composer require symfony/bridge
Then register the bundle in config/app.php.Symfony vs. Laravel Compatibility
ContainerInterface and Twig. In Laravel:
ContainerAware traits with Laravel’s Container binding.symfony/twig-bridge.config/services.yaml (Symfony) or Laravel’s AppServiceProvider.Routing Conflicts
dywee_blog routes overlap with Laravel’s default routes.routes/web.php:
Route::prefix('blog')->group(function () {
// Include dywee_blog routes here
});
Missing Documentation
Post fields).DyweeCoreBundle is required).Entity/ and Resources/config/ directories for clues. Example:
// Check Post entity for available methods
$post->setPublished(true); // Hypothetical method
Doctrine Events
prePersist) may not be wired.namespace App\EventListener;
use Dywee\BlogBundle\Entity\Post;
use Doctrine\ORM\Event\LifecycleEventArgs;
class PostListener {
public function prePersist(Post $post, LifecycleEventArgs $args) {
$post->setSlug(\Str::slug($post->getTitle()));
}
}
Register in config/services.yaml:
Dywee\BlogBundle\Entity\Post:
tags:
- { name: doctrine.event_listener, event: prePersist }
Check Entity Metadata Use Doctrine’s metadata tool to validate entities:
php bin/console doctrine:metadata:info --entity="Dywee\BlogBundle\Entity\Post"
Enable Debug Mode
In Symfony, set APP_DEBUG=true in .env. In Laravel, use:
$this->app->setDebugMode(true);
Log SQL Queries
Add to config/packages/doctrine.yaml:
dbal:
logging: true
logging:
db: "%kernel.logs_dir%/doctrine.log"
Custom Fields
Extend the Post entity and update migrations:
namespace App\Entity;
use Dywee\BlogBundle\Entity\Post as BasePost;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Post extends BasePost {
#[ORM\Column(type: 'string', length: 255)]
private $customField;
}
Override Templates
Copy Resources/views/ from the bundle to your project’s templates/ directory to customize Twig templates.
Add Validation Use Symfony’s validator or Laravel’s validation rules:
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity]
class Post extends BasePost {
#[Assert\NotBlank]
private $title;
}
How can I help you explore Laravel packages today?