Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] CI4 - Unable to Autoload Markdown Class
#9

(This post was last modified: 04-27-2019, 09:31 PM by John_Betong.)

For those who would like to try the following Markdown Github Repository:

https://github.com/michelf/php-markdown

1. Github clone or download into a \any\folder\of\your\choice\ 


2. Amend this file: app/Config/Autoload.php
PHP Code:
// ORIGINAL
// $psr4 = [
//    'Config'      => APPPATH . 'Config',
//    APP_NAMESPACE => APPPATH,                // For custom namespace
//    'App'         => APPPATH,                // To ensure filters, etc still found,
// ];

// NEW
$psr4 = [
 
   'Config'      => APPPATH 'Config',
 
   APP_NAMESPACE => APPPATH
 
   'App'         => APPPATH         
    
'Michelf' => '\any\folder\of\your\choice\php-markdown/Michelf/'
]; 



3. Markdown Class:
PHP Code:
<?php 
declare(strict_types=1);

namespace 
App\Controllers;

use 
CodeIgniter\Controller,
 
   Michelf\Markdown
 
   Michelf\SmartyPants// NOT REQUIRED

# ==========================================================
class Home extends BaseController
{

# ==========================================================
public function index()
{
 
 if(0):
 
   # DEMO
 
   $tmp  '#        Markdown H1'
 
         "\n##     Markdown H2"
 
         "\n###    Markdown H3"
 
         "\n####   Markdown H4"
 
         "\n#####  Markdown H5"
 
         "\n###### Markdown H6"
 
         "\nMarkdown paragraph stuff goes here"
 
         "\n"
 
         "\n\t 1. Order list one"
 
         "\n\t 2. Order list two"
 
         "\n\t 3. Order list three"
 
         "\n"
 
         ;
 
   $tmp Markdown::defaultTransform($tmp);
 
   echo $tmp;
 
   exit;

 
 else 
    
# USING Markdown files
 
   $data['header'] = $this->header();
 
   $top            file_get_contents(WRITEPATH .'markdown/BLURB-head.md');
 
   $body           file_get_contents(WRITEPATH .'markdown/BLURB-body.md');
 
   $footer         file_get_contents(WRITEPATH .'markdown/BLURB-footer.md');

 
   if(10):
 
     $md = new Markdown;
 
     $data['top'   $md->defaultTransform($top);
 
     $data['body'  $md->defaultTransform($body);
 
     $data['footer'] = $md->defaultTransform($footer);

 
   else:
 
     $data['top'   Markdown::defaultTransform($top);
 
     $data['body'  Markdown::defaultTransform($body);
 
     $data['footer'] = Markdown::defaultTransform($footer);
 
   endif 

    return view
('v_home'$data);
 
 endif 
}//


}/// 
Reply


Messages In This Thread
RE: CI4 - Unable to Autoload Markdown Class - by John_Betong - 04-27-2019, 09:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB