-
Notifications
You must be signed in to change notification settings - Fork 0
Docs Webapp
In Stubbles, everything that should be available via a web server is considered to be a web app. Be it a normal website, a rest interface or any other web service you want to offer.
It is supposed you have your Stubbles application already set up. See Installing and configuring Stubbles.
In your projects/$PROJECT/docroot directory edit .htaccess and add the following contents:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php [L]
This will make sure that all requests for non-existing files which are not an image, JavaScript or stylesheet file will be passed to the index.php file within this directory.
After that, edit the index.php file so it has the following contents:
<?php require '../../../bootstrap.php'; $projectPath = realpath(dirname(<u>FILE</u>) . '/../'); stubBootstrap::init(array('project' => $projectPath)); // load classes used in this file stubClassLoader::load('net::stubbles::ioc::stubApp', 'net::stubbles::ioc::module::stubPropertiesBindingModule', 'net::stubbles::webapp::stubUriConfigurator', 'net::stubbles::webapp::ioc::stubWebAppBindingModule' ); stubApp::createWebApp('net::stubbles::ioc::module::stubModeBindingModule', new stubPropertiesBindingModule($projectPath), 'net::stubbles::ipo::ioc::stubIpoBindingModule', 'net::stubbles::util::log::ioc::stubLogBindingModule', stubWebAppBindingModule::create(stubUriConfigurator::createWithXmlProcessorAsDefault() ->provideJsonRpc() ->provideRss() ->preIntercept('net::stubbles::websites::xml::stubShowLastXmlInterceptor') ->postIntercept('net::stubbles::ipo::interceptors::stubETagPostInterceptor') ) ) ->process(); ?>
First, we load the bootstrap file, after that we initialize Stubbles and load the required classes. Next comes the important part which determines web applications in Stubbles: you create a web app instance by passing a list of binding modules. For a web application the net::stubbles::webapp::ioc::stubWebAppBindingModule is used to setup the bindings for the web application, using the configuration done with the net::stubbles::webapp::stubUriConfigurator. This one is used to determine which processors should handle the request, and which pre- and postinterceptors should be used. For more details on both topics check processors and interceptors.