rmzamora/news-bundle
rmzamora/news-bundle is a Laravel/PHP package for adding news features to your application. It helps developers organize and publish news content, offering a simple starting point for building news, blog, or article sections without heavy setup.
This package is the rmzamora fork of sonata-project/news-bundle, a Sonata Admin–based news/blog bundle for Symfony. It is archived and unmaintained (0 stars, 0 dependents), so treat it as a legacy codebase you inherit rather than a dependency you adopt. Before installing, open the fork's composer.json and confirm the PHP and Symfony constraints — the fork pins an era of Symfony (likely 2.x/3.x), and Composer will refuse to resolve it against a modern application.
Minimal path:
composer require rmzamora/news-bundle (add the repository/VCS entry if it is not on Packagist).SonataAdminBundle, SonataDoctrineORMAdminBundle, SonataBlockBundle, and SonataClassificationBundle (used for tags/collections). Without these, admin routes and blocks silently fail to render.Resources/config/routing/*.xml) — the front controllers (news, news_view, news_feed, comment create) and admin routes are separate files.bin/console config:dump-reference sonata_news) and create a sonata_news.yaml with at least title, link, salt, per_page, and the entity class mapping.Entity/News, NewsCategory, NewsComment, or map your extended subclasses under sonata_news.class.news etc. Run doctrine:schema:update/migrations.Where to look first: Entity/ and Document/ (mapping and getSalt()), Admin/NewsAdmin.php (form fields, batch actions), Resources/config/admin.xml and Resources/config/routing/ (service IDs and route names), Block/ (recent posts, archive, RSS blocks), and Controller/NewsController.php + Controller/NewsFeedController.php (front-end behavior).
First use case: publish a News item with a category and publicationDateStart in the past, confirm it appears at the configured /news list route and in the RSS feed, then drop {{ sonata_block_render({ 'type': 'sonata.news.block.recent_posts' }) }} into a layout to verify block wiring.
BaseNews/BaseNewsCategory, keep the bundle untouched, and point sonata_news.class.* config at your classes. Same for Admin/NewsAdmin: subclass it, change configureFormFields()/configureDatagridFilters(), and override the sonata.admin.news service definition (or use sonata.admin.extension for additive changes).NewsPermalinkGenerator builds a dated slug route (sonata_news_view). If you need SEO-friendly or localized URLs, implement the permalink generator interface and replace the sonata.news.permalink.generator service.sonata.news.manager.news (NewsManagerInterface) with findLatest, findByCategory, findByDateRange, and the pager helpers. Front-end controllers are thin and easy to copy if you need custom actions.sonata_block_render. If you need a different query, extend the block service and re-register the service ID.templates/bundles/SonataNewsBundle/... on Flex, app/Resources/SonataNewsBundle/views/... on older apps). The feed template and list/item partials are the ones you'll touch most.sonata_news.comment and use the comment-create route from your item template. The comment hash is validated against the configured salt. Moderation happens through NewsCommentAdmin.NewsCategory while free-form tags/collections typically come from SonataClassificationBundle; make sure the admin form context is configured for both or you get missing-field errors on save.SonataFormatterBundle (or equivalent) is installed if you expect rich HTML and markdown, otherwise you'll store and output raw strings.patches in composer or a local src/ bundle) and pin every transitive Sonata dependency. Do not start greenfield work on this.News::getSalt() returns the configured salt; changing sonata_news.comment.salt invalidates every previously generated comment hash and breaks existing threads. Set it once, keep it in env, never rotate casually.publicationDateStart drives visibility. Feeds and list blocks filter on it, not createdAt. A post saved without a publication date silently disappears from blocks and RSS even though it exists in admin.news, news_view, news_feed); importing them at the app root can clash. Prefix or import under a scope.sonata_block config; new posts may not appear until TTL expiry. Lower the TTL in dev and verify with the block cache disabled when debugging "missing post" reports.bin/console debug:router | grep sonata_news, debug:container sonata.news.manager.news, and debug:container --tag=sonata.block will resolve most wiring confusion faster than reading the archived README.prePersist/preUpdate for slug/date normalization, a custom NewsManager to centralize published-only queries, and the block service layer for anything you'd otherwise hack into templates.How can I help you explore Laravel packages today?