/** * @param string $config * * @return \Songbird\App */ public static function createApplication($config = '') { $app = new App(require __DIR__ . '/../config/di.php'); $app->add('Config', new Config($config)); $app->add('Symfony\\Component\\HttpFoundation\\Response', new Response()); $app->add('Symfony\\Component\\HttpFoundation\\Request', Request::createFromGlobals()); $app->add('Filesystem', 'League\\Flysystem\\Filesystem')->withArgument(new CachedAdapter(new Adapter($app->config('app.paths.resources')), new CacheStore())); $app->get('Logger')->pushHandler(new StreamHandler(vsprintf('%s/songbird-%s.log', [$app->config('app.paths.log'), date('Y-d-m')]), Logger::INFO)); $app->inflector('League\\Container\\ContainerAwareInterface')->invokeMethod('setContainer', [$app]); $app->inflector('League\\Event\\EmitterAwareInterface')->invokeMethod('setEmitter', [$app->get('Emitter')]); $app->inflector('Psr\\Log\\LoggerAwareInterface')->invokeMethod('setLogger', [$app->get('Logger')]); $app->inflector('Songbird\\FilesystemAwareInterface')->invokeMethod('setFilesystem', ['Filesystem']); $app->add('Repository', $app->get('RepositoryFactory')->createContentRepository()); return $app; }
/** * {inheritdoc} */ public static function initialize(App $app = null) { $app->add('routes', function ($c, $name) use($app) { $routes = $app->get($name); $routes['admin-shop'] = 'shop/admin'; return $routes; }); $nav = []; if (User::is('admin')) { $nav['/admin-shop/categories'] = 'Kategori'; $nav['/admin-shop/customers'] = 'Pelanggan'; $nav['/admin-shop/banners'] = 'Banner'; $nav['/admin-shop/products'] = 'Produk'; $nav['/admin-shop/reports'] = 'Laporan'; } else { $nav['/admin-shop/account'] = 'Akun saya'; } $nav['/admin-shop/orders'] = 'Order'; $app->get('admin-menu')->prepend($nav); }
if (isset($classes[$class])) { require_once $classes[$class]; } }); /** * Memuat File konfigurasi */ $configs = new Config(require 'system/configs.php'); /** * Inisialisasi Aplikasi dan menerapkan konfigurasi */ $app = new App($configs); /** * Mengaktifkan Mode Debug, ganti 'true' ke 'false' untuk mematikan mode ini. * Atau cukup dengan menghapus baris tersebut. */ App::debug($configs->get('debug')); /** * Function Loader * Memuat semua file yang ada dalam direktory 'helpers'. */ foreach (glob(__DIR__ . '/helpers/**.php') as $function) { require_once $function; } /** * Inisialisasi Class Database jika terdapat pengaturan Database dalam file Konfigurasi. */ $app->add('db', function ($c) { return new Db($c->get('db')); }); return $app;
if (!isset($_POST[$field])) { if ($error_fields) { $error_fields .= ', '; } $error_fields .= $field; } } } if ($error_fields) { $this->writeJSON(array('__raw' => true, 'error' => true, 'message' => 'Required field(s) ' . $error_fields . ' is missing or empty'), 400, '400 Bad Request'); } } } //create API Appication $app = new App(array('view' => new \Slim\Views\Twig())); $app->add(new \Slim\Middleware\ContentTypes()); $app->notFound(function () use($app) { $app->writeJSON(null, 404, 'Not Found'); }); $app->error(function (\Exception $e) use($app) { $app->writeJSON(null, 500, 'Internal Server Error'); }); $app->get('/', function () use($app) { echo "API SERVICES"; }); $app->map('/:ver/:args+/', 'App::Authenticate', function ($ver, $args) use($app) { $main = __DIR__ . '/' . $ver . '/main.php'; if (count($args)) { $_POST = $app->request->post(); $app->arguments = array_values($args); $fname = array_shift($args);
#!/usr/bin/env php <?php require __DIR__ . '/../vendor/autoload.php'; use App\Command; $application = new App('Name of your App', '@package_version@'); $application->add(new Command\HelloCommand()); $application->run();
#!/usr/bin/env php <?php require __DIR__ . '/../vendor/autoload.php'; use App\Command; $application = new App('Vagrant Manager', '@package_version@'); $application->add($status = new Command\StatusCommand()); $application->setDefaultCommand($status->getName()); $application->add(new Command\Vagrant\UpCommand()); $application->add(new Command\Vagrant\Up\AllCommand()); $application->add(new Command\Vagrant\SuspendCommand()); $application->add(new Command\Vagrant\Suspend\AllCommand()); $application->add(new Command\Vagrant\RestartCommand()); $application->add(new Command\Vagrant\Restart\AllCommand()); $application->add(new Command\Vagrant\HaltCommand()); $application->add(new Command\Vagrant\Halt\AllCommand()); $application->add(new Command\Vagrant\SshCommand()); $application->add(new Command\SelfupdateCommand()); $application->add(new Command\HelpCommand()); $application->add(new Command\AboutCommand()); $application->run();