* 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. */ //Show all errors error_reporting(E_ALL); ini_set('display_errors', '1'); //This autoload path is for loading current version of phramework require __DIR__ . '/../vendor/autoload.php'; //define controller namespace, as shortcut define('NS', '\\Phramework\\Examples\\API\\Controllers\\'); use Phramework\Phramework; /** * @package examples/post * Define APP as function */ $APP = function () { //Include settings $settings = (include __DIR__ . '/../settings.php'); $URIStrategy = new \Phramework\URIStrategy\URITemplate([['book/', NS . 'BookController', 'GET', Phramework::METHOD_GET], ['book/{id}', NS . 'BookController', 'GETSingle', Phramework::METHOD_GET], ['book/', NS . 'BookController', 'POST', Phramework::METHOD_POST]]); //Initialize API $phramework = new Phramework($settings, $URIStrategy); unset($settings); Phramework::setViewer(\Phramework\Viewers\JSON::class); //Execute API $phramework->invoke(); }; /** * Execute APP */ $APP();
<?php //Show all errors error_reporting(E_ALL); ini_set('display_errors', '1'); //This autoload path is for loading current version of phramework require __DIR__ . '/../vendor/autoload.php'; define('NS', '\\Phramework\\Examples\\Blog\\Controllers\\'); use Phramework\Phramework; /** * Define APP as function */ $APP = function () { //Include settings $settings = (include __DIR__ . '/../settings.php'); $uriStrategy = new \Phramework\URIStrategy\URITemplate([['/', NS . 'PostController', 'GET', Phramework::METHOD_GET], ['post/', NS . 'PostController', 'GET', Phramework::METHOD_GET], ['post/{id}', NS . 'PostController', 'GETSingle', Phramework::METHOD_GET], ['editor', NS . 'EditorController', 'GET', Phramework::METHOD_GET], ['editor', NS . 'EditorController', 'POST', Phramework::METHOD_POST], ['secure', NS . 'SecureController', 'GET', Phramework::METHOD_GET, true]]); //Initialize API $phramework = new Phramework($settings, $uriStrategy); unset($settings); Phramework::setViewer(\Phramework\Examples\Blog\Viewers\Viewer::class); //Execute API $phramework->invoke(); }; /** * Execute APP */ $APP();