Download the PHP package melazhari/sulu-admin-bar-bundle without Composer

On this page you can find all versions of the php package melazhari/sulu-admin-bar-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sulu-admin-bar-bundle

AdminBarBundle

CI Latest Version

A frontend admin bar for Sulu CMS. Backend users who are logged into the Sulu admin see a slim toolbar on top of the website with direct links to edit the content they are looking at. Anonymous visitors see nothing — and the page HTML stays fully HTTP cacheable.

Features

Installation

Quick install (recommended)

Install the package and run the installer with the PHP binary your project uses (the installer needs PHP >= 7.3):

Alternatively, copy the bundle into your Sulu project (e.g. to bundles/AdminBarBundle) and run:

It performs every manual step listed below — composer autoload entry, bundle registration, route import, default configuration, the security access_control rule, {{ sulu_admin_bar() }} in templates/base.html.twig, composer dump-autoload, assets:install and cache clearing.

The installer is idempotent (running it twice is safe), reports a [WARN] with manual instructions for anything it cannot patch automatically (e.g. a heavily customized security config), and accepts --skip-commands if you only want the file changes without running composer/console commands.

Manual installation

1. Register the code — as a composer package:

Or, as a local bundle copied to bundles/AdminBarBundle, add the namespace to your project's composer.json and dump the autoloader:

2. Enable the bundle:

3. Import the route:

4. Allow anonymous access to the endpoint. It must stay inside the admin firewall but must not trigger the admin login — it answers 401 itself. Add this rule above the admin catch-all, using your project's admin URL prefix (/admin in the Sulu skeleton):

On Symfony versions without the PUBLIC_ACCESS attribute use IS_AUTHENTICATED_ANONYMOUSLY instead (the installer picks whichever the file already uses).

5. Install the assets:

6. Add the bar to your base layout, right before </body>:

Finally clear the caches:

Log into the admin once, then open the website: the bar appears.

How it works

In a standard Sulu setup only the admin (^/admin) is behind a firewall and website responses are cached by the HTTP cache. Rendering a user-specific bar directly into the page HTML would therefore either never see the admin session or leak the bar into cached responses. This bundle avoids both:

  1. {{ sulu_admin_bar() }} renders a tiny, visitor-independent loader <script> carrying the current page context (webspace, locale, page uuid or entity id) as data attributes — safe to cache.
  2. While using the admin, a response listener sets a JS-readable session marker cookie (sulu_admin_bar) and removes it again on logout. The cookie carries no data; it only tells the loader that an admin session exists, so anonymous visitors never call the endpoint at all.
  3. When the marker is present, the script calls GET <admin-prefix>/admin-bar (/admin/admin-bar by default), which runs through the admin firewall, so the Sulu admin session is available there. The prefix is detected from the project's admin firewall pattern automatically — see admin_route_prefix below.
  4. If the user is authenticated, the endpoint returns their name and the permission-checked admin URLs; the script injects the stylesheet and the bar. Otherwise it returns 401, the stale marker is dropped and nothing is rendered.

What the bar shows

Element Behaviour
Sulu logo Links to the Sulu admin.
User name Full name of the logged-in Sulu user (falls back to the username).
Edit Opens the current page or entity in its Sulu admin edit form.
Add new Opens the creation form for the current content type; outside of any content context it opens the page list of the webspace.
Logout Calls the Sulu admin logout route.

Permissions are checked server-side with Sulu's SecurityChecker — against the sulu.webspaces.<webspace> security context for pages and against the entity's admin views (plus the optional configured security_context) for custom entities — so links the user is not allowed to use are never rendered.

Configuration

Everything works without configuration. The full reference:

Custom entities

Sulu projects often route Doctrine entities through the RouteBundle with a RouteDefaultsProviderInterface implementation. When such a provider exposes the entity as a request attribute in its route defaults:

the admin bar links to the entity's admin form automatically. Detection is convention based: any request attribute holding an object with a RESOURCE_KEY class constant (the standard Sulu entity convention) and a scalar getId() is linkable.

Entity detail pages that are not served through the Sulu route system but by plain Symfony routes (e.g. /formation/{slug}/{id}) carry no entity object in the request attributes — those are detected automatically too. The loader forwards the route name and URL path together with the numeric id route parameter, and the authenticated endpoint matches them against the Doctrine entities following the RESOURCE_KEY convention (resource key and class short name, tolerant of singular/plural and _/-/. separators: a route formation or a path segment formation-domains finds the formations / formation_domains entities).

The admin URLs are just as dynamic: the endpoint looks the edit and add form views up in Sulu's view registry (sulu_admin.view_registry) by resource key and uses the actual registered view paths. Because Admin classes register views per user, a user without access to the entity simply gets no link.

Configuration under admin_bar.entities is only needed for two cases:

Notes:

Security notes

Compatibility

The bundle intentionally uses the classic Bundle + DI extension pattern and PHP 7.2 compatible syntax so the same code runs on legacy Sulu 2 projects and current Sulu 3 projects. The current page is detected via the object request attribute on Sulu 3 and via the structure attribute (PageBridge) on Sulu 2; admin URL patterns and the sulu.webspaces.<webspace> security context are identical in both major versions.

Bundle structure

License

Released under the MIT license.


All versions of sulu-admin-bar-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
doctrine/persistence Version ^1.3 || ^2.0 || ^3.0 || ^4.0
sulu/sulu Version ^2.0 || ^3.0
symfony/asset Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/config Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/dependency-injection Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/http-foundation Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/http-kernel Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/routing Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/security-core Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/twig-bridge Version ^4.4 || ^5.4 || ^6.4 || ^7.0
symfony/yaml Version ^4.4 || ^5.4 || ^6.4 || ^7.0
twig/twig Version ^2.13 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package melazhari/sulu-admin-bar-bundle contains the following files

Loading the files please wait ...