Exemplo n.º 1
0
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
define('MAINTENANCE_MODE', 'install');
// Initialize libraries
require_once dirname(__FILE__) . '/libs/init.php';
use Mibew\Application;
use Mibew\Authentication\DummyAuthenticationManager;
use Mibew\Routing\Loader\DummyPluginLoader;
use Mibew\Routing\Router;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Loader\YamlFileLoader;
// Prepare router
$file_locator = new FileLocator(array(MIBEW_FS_ROOT));
$route_loader = new YamlFileLoader($file_locator);
$loader_resolver = new LoaderResolver(array($route_loader, new DummyPluginLoader()));
$router = new Router($route_loader, 'configs/routing_install.yml');
$application = new Application($router, new DummyAuthenticationManager());
// Process request
$request = Request::createFromGlobals();
$response = $application->handleRequest($request);
// Send response to the user
$response->send();
Exemplo n.º 2
0
use Mibew\Authentication\AuthenticationManager;
use Mibew\Cache\CacheFactory;
use Mibew\Mail\MailerFactory;
use Mibew\Routing\Router;
use Mibew\Routing\Loader\CacheLoader;
use Mibew\Routing\Loader\PluginLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Loader\YamlFileLoader;
$configs = load_system_configs();
// Prepare the cache
$cache_factory = new CacheFactory($configs['cache']);
// For now directory for cache files cannot be changed via the configs file.
// TODO: Evaluate possibility of using custom cache directory.
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
// The main route loader which loads nothig but works as a cache proxy for other
// loaders.
$route_loader = new CacheLoader($cache_factory->getCache());
// Real loaders are attached via the resolver.
$loader_resolver = new LoaderResolver(array($route_loader, new YamlFileLoader(new FileLocator(array(MIBEW_FS_ROOT))), new PluginLoader()));
$router = new Router($route_loader, 'configs/routing.yml');
$application = new Application($router, new AuthenticationManager());
$application->setCache($cache_factory->getCache());
// Use custom config-dependent mailer factory
$application->setMailerFactory(new MailerFactory($configs['mailer']));
// Process request
$request = Request::createFromGlobals();
$response = $application->handleRequest($request);
// Send response to the user
$response->send();