示例#1
0
<?php

namespace App\Routes;

use Anslo\App;
use Service;
use Data;
App::section("/api", function () {
    App::get("/", function (Service $service) {
        $service->status = true;
        $service->message = "You have reached the api";
        return $service;
    });
});
示例#2
0
<?php

namespace App\Routes\Otherwise;

use Anslo\App;
use Scope;
use System;
App::otherwise(function (Scope $scope, System $system) {
    $scope->system = $system;
    return $scope->view("wrongroute");
});
示例#3
0
<?php

namespace App\Routes\Pages;

use Anslo\App;
use Scope;
use Data;
use App\User;
App::get("/", function (Scope $scope) {
    return $scope->view("home");
});
App::get("/anslo/", function (Scope $scope) {
    return $scope->view("anslo");
});
App::get("/data", function (Scope $scope) {
    $scope->firstUser = User::find(1);
    $scope->activeUsers = User::where("is_activated")->equal(1)->fetch();
    $scope->allUsers = User::all();
    return $scope;
});
示例#4
0
            Cli::pose("Namespace (dot delimited): ", function ($namespace) use($modelName) {
                $pathToModel = "";
                $namespaceOfModel = "";
                $namespaceParts = explode(".", $namespace);
                foreach ($namespaceParts as $part) {
                    $pathToModel .= strtolower($part) . "/";
                    $namespaceOfModel .= "\\" . $part;
                }
                $file = "./app/{$pathToModel}{$modelName}.php";
                $namespace = $namespaceOfModel === "\\" ? "" : $namespaceOfModel;
                $template = file_get_contents("./system/file-templates/model");
                $model = strtr($template, ["{{model}}" => $modelName, "{{namespace}}" => $namespace]);
                if (file_exists($file)) {
                    return "Model ({$modelName}) already exists. Operation aborted";
                }
                if (App::forcePut($file, $model, true)) {
                    return "Model ({$modelName}) was created successfully.";
                }
                return "Model ({$modelName}) failed to be created";
            });
        } else {
            return "Cannot create a Model without a name";
        }
    });
}, file_get_contents(dirname(__FILE__) . "/console/descriptions/ng.html"));
Cli::command("build ng", function () {
    $output = shell_exec('gulp ng');
    return $output;
}, file_get_contents(dirname(__FILE__) . "/console/descriptions/ng.html"));
Cli::command("build mjml", function () {
    $output = shell_exec('gulp ng');
示例#5
0
<?php

namespace App\Routes\Exception;

use Anslo\App;
App::onException(function ($exception) {
    return $exception->getMessage();
});
示例#6
0
<?php

session_start();
use Anslo\App;
use Anslo\Route;
//Composer
require_once "../vendor/autoload.php";
$bootstrap = App::bootstrap(dirname(__DIR__));
define("ROOTURI", "/Anslo/App");
//Settings
require_once "../settings/connections.php";
require_once "../settings/view.php";
//require_once("../settings/console.php");
//Include Routes (You can what you want)
require_once "../app/routes/api.php";
require_once "../app/routes/contracts.php";
require_once "../app/routes/exception.php";
require_once "../app/routes/otherwise.php";
require_once "../app/routes/pages.php";
//find the route
App::find($bootstrap->route);