Download the PHP package tobento/app-view without Composer
On this page you can find all versions of the php package tobento/app-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package app-view
App View
The app view includes support for creating menus, forms and more for creating any kind of web applications. It comes with a default layout using the Basis Css which you may use or not. Some App Bundles may rely on this though.
Table of Contents
- Getting Started
- Requirements
- Documentation
- App
- View Boot
- Rendering Views
- Global View Data And Variables
- Available View Macros
- Menus Boot
- Form Boot
- CSRF Protection
- Form Messages
- Messages Boot
- Breadcrumb Boot
- Table Boot
- Default Layout
- Views
- Exception Views
- Themes
- Theme Views
- Theme Assets
- Credits
Getting Started
Add the latest version of the app view project running this command.
Requirements
- PHP 8.0 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
View Boot
The view boot does the following:
- Migrates views and css assets for default layout
- Implements ViewInterface
- Adds global view data from different services if available
- Adds multiple view macros
Rendering Views
You can render views in several ways:
Using the app
Using autowiring
You can also request the in any class resolved by the app.
Using the view boot
Check out the View Service to learn more about it.
Using the responser
If you have booted the App Http - Requester And Responser boot, you may use the method:
Global View Data And Variables
It adds the following global view data and variables accessible in your view files:
$htmlLang / $locale
Code snippet from the view boot:
$routeName
Code snippet from the view boot:
Adding global data and variables
You may add more global data by using a boot:
Available View Macros
app
Returns the app instance.
assetPath
The function returns the fully qualified path to your application's asset directory.
menu
Returns the menu for the specified name.
Check out the Menu Service to learn more about it in general.
trans / etrans
Returns the message translated by the Translator if available within the app.
By default, the translator is not available, you might install the App Translation bundle to do so.
routeUrl
Returns the url for the specified route if is available within the app which is the case if the App Http - Routing Boot has been booted.
tagAttributes
Returns the attributes for the specified tag name.
Check out the Tag Service - Attributes Interface to learn more about it in general.
date / dateTime / formatDate
You may use , and methods to format and display any dates using the Date Formatter.
Menus Boot
The menus boot does the following:
- Implements MenusInterface
- Adds menu view macro
Check out the Menu Service to learn more about it in general.
Using menus boot
You may add menu items using the menus boot:
Using the app on method
You may add menu items only if the menus is requested from the app.
Form Boot
The form boot does the following:
- Implements FormFactoryInterface
- Adds form view macro
- Adds VerifyCsrfToken middleware
This boot requires the app-http bundle:
Check out the Form Service to learn more about it in general.
You might boot the App Http - Error Handler Boot which already handles exceptions caused by the form.
CSRF Protection
CSRF protection is implemented and csrf token will be verified by the registered VerifyCsrfToken Middleware.
CSRF Token
The form boot adds the CSRF Token to the global view data accessible in your view files:
X-CSRF-TOKEN
In addition to checking for the CSRF token as a POST parameter, the VerifyCsrfToken Middleware will also check for the request header.
When using the Default Layout, in the view file , the token will be stored in a HTML meta tag named :
You may use this meta tag to get the token while setting the header:
Form Messages
As is the default implementation you can pass messages to your form fields by the following way:
In your view file:
Messages Boot
The messages boot does the following:
Renders the passed view messages if they are an instance of :
Check out the Message Service to learn more about it in general.
Responser messages
Renders the message from the responser, if you have booted the App Http - Requester And Responser booted.
View files
In your view files, render the messages view:
Breadcrumb Boot
The breadcrumb boot does the following:
Adds the breadcrumb view and creates breadcrumb menu based on the main menu using the global view data to determine the active menu tree.
View files
In your view files, render the breadcrumb view:
You may set the active menu tree using the parameter:
You may use the parameter to specify the menu tree to be used, which may be useful if you want to modify the breadcrumb menu:
You may use the parameter to specify a custom breadcrumb menu:
Table Boot
The table boot does the following:
- Adds table.css to your specified public css directory
- Adds table view macro
View file
Check out the Table Service to learn more about it in general.
Default Layout
Views
The default layout uses the and the Basis Css to style the view files.
A view file using the view boots may look like:
It is not recommended to alter existing views and assets as any app update may overwrite these files. Instead create a Theme.
Exception Views
The following exception views are available in your view directory:
You might install and boot the App Http - Error Handler Boot which will use these views to render html and xml excpetions.
Example using the responser to render an exception view
If you have booted the App Http - Requester And Responser boot, you may use the method:
Themes
Theme Views
You may create a "theme" to customize existing views and assets, otherwise any app update may overwrite these files.
First, create a theme boot:
Next, you just place the view file you want to customize in your specified directory. If the view file does not exist, it uses the default view file.
Theme Assets
You can handle your custom assets in the following ways:
Replacing assets
In your customized views you may just replace the assets by your custom assets:
Using an asset handler
You may create an asset handler to minify, combine or replace assets.
A default asset handler is in development to to minify, combine or replace assets!
Credits
- Tobias Strub
- All Contributors
All versions of app-view with dependencies
tobento/app Version ^1.0
tobento/app-migration Version ^1.0
tobento/service-view Version ^1.0
tobento/service-uri Version ^1.0
tobento/service-menu Version ^1.1.0
tobento/service-form Version ^1.0
tobento/service-table Version ^1.0.2
tobento/service-language Version ^1.0
tobento/service-translation Version ^1.0
tobento/service-dater Version ^1.0.2
tobento/css-basis Version ^1.0