title: Can i combine Slim Framework with plain PHP
body: <p>I just started with PHP not too long ago and have done some small projects with just plain PHP + Ajax + html.
  I’m more comfortable with procedural code than OOP. I can still use OOP library of Pakagist. But i want to go slow the first time using a framework.</p>
  <p>I want to do a serious new project with Slim but in a procedural way.
  My ideas:</p>
  <p>Only use routing to require a view
  My Url: <code>example.com/?r={child router}&amp;page={view}</code></p>
  <p>Routing: Only used to require to a child router and forward $parameter.
  Template &amp; View: will receive a json result from ajax callback, my app will heavy ajax.</p>
  <pre><code>$app-&gt;get('/}', function() {
      require &quot;index.view&quot;;
  });
  $app-&gt;get('/{route}/{page}', function (Request $request, Response $response, array $args) {
      $route = $args['route'] ? $args['route'] : &quot;&quot;;
      $page = $args['page'] ? $args['page'] : &quot;&quot;;
  // I have a folder View contains folder User
      if folder_exists(&quot;route/&quot; . $route)
      {
          if file_exists(&quot;view/&quot; . $route . &quot;/&quot; . $page . &quot;.php&quot;)
          {
              require (&quot;view/&quot; . $route . &quot;/&quot; . $page . &quot;.php&quot;);
          } else {
              require (&quot;view/&quot; . $route . &quot;/def_page.php&quot;);
          }
      } else {
        header (Location: index.php);
      }
  });
  
  
  // example.com/?r=user&amp;page=register
  // will require view/user/register.php
  
  // example.com/?r=admin&amp;page=login
  // will require view/admin/login.php
  </code></pre>
  <p>And all my logic will be handled through an ajax route like</p>
  <pre><code>$app-&gt;get('/ajax/{route}/{action}', function (Request $request, Response $response, array $args) {
      $route = $args['route'] ? $args['route'] : &quot;&quot;;
      $action= $args['action'] ? $args['action'] : &quot;&quot;;
  // I have a folder View contains folder User
      
          if file_exists(&quot;ajax/&quot; . $route . &quot;/&quot; . $page . &quot;.php&quot;)
          {
              require (&quot;ajax/&quot; . $route . &quot;/&quot; . $page . &quot;.php&quot;);
          } else {
              $result = [
                          'status' =&gt; false,
                          'msg' =&gt; 'failed'
              ]
              return json_encode($result);
          }
  });
  
  // example.com/?r=ajax&amp;action=login
  // will require ajax/user/login.php
  </code></pre>
  <p>Please help me and let me know if this doesn’t fit in Slim or anything bad.
  Thanks for help.</p>
  <p>UPDATE:
  I used this route library.
  It very simple and nice.
  Slim 4, he's slim but very complex.</p>
  <pre><code>&lt;?php
  use Core\Libs\View;
  use Core\Libs\Config;
  
  $route = new AltoRouter();
  
  $route-&gt;map( 'GET', '/', ['route' =&gt; 'core', 'page' =&gt; 'landing']);
  
  $route-&gt;map( 'GET', '/user', ['route' =&gt; 'user', 'page' =&gt; 'home']);
  
  $route-&gt;map( 'GET', '/user/login', ['route' =&gt; 'user', 'page' =&gt; 'login']);
  
  $match = $route-&gt;match();
  
  ?&gt;
      Target: &lt;?php var_dump($match['target']); ?&gt;&lt;br&gt;
      Params: &lt;?php var_dump($match['params']); ?&gt;&lt;br&gt;
      Name:   &lt;?php var_dump($match['name']); ?&gt;&lt;br&gt;
  &lt;?
  
  if( is_array($match) &amp;&amp; isset( $match['target'] ) ) {
      //call_user_func_array( $match['target'], $match['params'] );
      var_dump($match);
  } else {
      header( $_SERVER[&quot;SERVER_PROTOCOL&quot;] . ' 404 Not Found');
      echo 'Không tìm thấy trang';
  }
  </code></pre>