Create new page in phpixie

A PHPixie fan!

To create a new page in PHPixie, you'll need to follow these steps:

Step 1: Create a new controller

In PHPixie, controllers are responsible for handling requests and returning responses. To create a new controller, run the following command in your terminal:

phpixie generate:controller MyNewPage

This will create a new file MyNewPageController.php in your app/controllers directory.

Step 2: Define the controller actions

In the MyNewPageController.php file, define the actions that will be executed when the page is requested. For example:

<?php

use PHPixie\Controller;

class MyNewPageController extends Controller
{
    public function indexAction()
    {
        // Code to be executed when the page is requested
    }
}

In this example, we've defined an indexAction method that will be executed when the page is requested.

Step 3: Create a new route

To map the new controller action to a URL, you need to create a new route. Run the following command:

phpixie generate:route my-new-page

This will create a new file my-new-page.php in your app/routes directory.

Step 4: Define the route

In the my-new-page.php file, define the route:

<?php

use PHPixie\Route;

Route::get('/my-new-page', 'MyNewPageController@indexAction');

This route maps the URL /my-new-page to the indexAction method of the MyNewPageController controller.

Step 5: Create the page template

Create a new file my-new-page.php in your app/views directory. This file will contain the HTML template for your new page.

Step 6: Render the page

In the indexAction method of your controller, use the render method to render the page template:

public function indexAction()
{
    $this->render('my-new-page');
}

That's it! You've created a new page in PHPixie.

Remember to update your app/config/routes.php file to include the new route:

<?php

use PHPixie\Route;

Route::map('/my-new-page', 'my-new-page');

Now, when you navigate to /my-new-page in your browser, you should see your new page rendered.