Skip to content
micahbaumann edited this page Oct 12, 2022 · 2 revisions

Examples - Simple Example

  1. Install the URLS framework (see this guide).
  2. Create a new file named blog-home.php and fill it with:
    <!DOCTYPE html>
    <html>
    <head>
       <meta charset="utf-8">
       <title>My Blog - Home</title>
    </head>
    <body>
    <h1>This is my Blog</h1>
    <p>Welcome!</p>
    </body>
    </html>
  3. Open the file you chose as your settings in your editor. It should look something like this:
    <?php
    /*
    URLS framework url config file.
    
    Add your paths here:
    ex. $urls->path('blog/', 'blog-home.php', true);
    */
    include 'urls/Urls.php';
    Urls::$base = '/';
    
    $urls = new Urls;
    
    
    $urls->exe();
    
    ?>
  4. Add $urls->path('blog/', 'blog-home.php', true); to your settings file under include 'urls/Urls.php';. Here is the file now:
    <?php
    /*
    URLS framework url config file.
    
    Add your paths here:
    ex. $urls->path('blog/', 'blog-home.php', true);
    */
    include 'urls/Urls.php';
    Urls::$base = '/';
    
    $urls = new Urls;
    $urls->path('blog/', 'blog-home.php', true);
    
    $urls->exe();
    
    ?>
  5. If you did not specify a base url, go to http://yourdomain.com/blog/. If you did specify a base url, go to http://yourdomain.com/<your base url>/blog/. You should see the contents of the the blog-home.php file. Output

For more examples see GUIDES.
The source code for this example is at https://github.com/urls-framework/URLS/tree/main/examples/Simple%20Example/src.

Clone this wiki locally