Karmate PHP Framework

1.0.2


Introduction


First of all, if you are using Karmate, you are aware of Karmate. Thank you for being supportive of these values. You are awesome!
In the name of earning as unrequited assistance, labor, different cultures and society!

This documentation is designed to tell you how to make Karmate ready to install, how to install it, how to use it most simply and functionally.

Requirements

Windows or Linux server

  1. PHP 7
  2. Apache2 mod_rewrite module
  3. And a lot of creativity!

Before you install Karmate, you must make sure that you meet the above requirements.

Getting Started #back to top

Move the downloaded Karmate compressed file to where you want it to work.

Karmate needs file permissions to work.You can do this from the linux terminal, from the ftp client you are using or from the desktop interface.

                                An ubuntu server example:
                                sudo su chmod 777 /var/www/karmate-1-0-0/ -R
                                

How to create a new project #back to top

Before you get into this, you have to have installed Karmate completely. Getting started.


Change the default application

Open file :

root_dir -> configurations -> app.php
                        

You should make sure that the directory names (just the directory, not file) are in lower case when doing the following operations. Karmate autoloader only supports lowercase letters for directory names.


find the line and replace the nail with the your projects name.

'default_app'               => 'karmate'
                        

Create a folder in the following directory to be the same as your project name.

root dir -> apps
                        

You must create a config for your project.

Create a directory called "config" in the directory that is the same as your project name.

root dir -> apps -> yourproject -> config
                        

Create a config.php file.

root dir -> apps -> yourproject -> config -> config.php
                        
<?php  return [

    #TEMPLATE DEFAULTS
    'default_lang'           => 'en'                 ,
    'default_controller'     => 'Homepage'           ,
    'default_function'       => 'Opening'            ,

    #DB CONFIG
    #CONS -> NAME_DB
    'databaseConfig'         => array(
    'name'  => 'database.php',
    'name2' =>'anotherdb.php' #Another db
                                     ),

    #TEMPLATE DIRECTORYS
    'controllers'            => 'controllers'        ,
    'models'                 => 'models'             ,
    'views'                  => 'views'              ,
    'themes'                 => 'themes'             ,
    'error_pages'            => 'error_pages'        ,
    'autorun'                => 'autorun'            ,
    'public'                 => 'public'			 ,
    'lang'					 => 'lang'
    ];
                        

you need to create the following directories in the project directory. The mandatory ones are indicated by "*".


controllers*
views*
models*
error_pages*
                        

Now we need to create our default controller :)

Create homepage.php in the following directory.
root dir -> apps -> yourproject -> controllers -> Homepage.php
                        
<?php
class Homepage
{
    public function Opening()
    {
        echo "Hello World :)";
    }
}
                        

See also

Config customizations View usage

Config customizations #back to top

Config customizations Karmate is available for flexing to the end of the Flexible PHP Framework.

#TEMPLATE DEFAULTS

Language option

'default_lang'           => 'en'                 ,
                        

If you write abbreviations for your own language instead of 'en', you will receive error and information notifications in the Karmate Framework library in your own language. Also, if the progeny is using language support, the visitor who accesses the progeny first displays the progeny on this page.

Default controller and default function option

'default_controller'     => 'Homepage'           ,
'default_function'       => 'Opening'            ,
                        

Instead of 'homepage', the controller is the file that will run on startup.

Instead of 'Opening', the function is the constructor class of the controller.

You can use the __construct () function together with the 'Opening' function :)

see also

Language supported projects with Karmate

Config customizations Karmate is available for flexing to the end of the Flexible PHP Framework.

#DB CONFIG

Database settings

'databaseConfig'         => array(
                            'name'  => 'database.php',
                            'name2' =>'anotherdb.php' #Another db
                            ),
                        

Instead of 'database.php', the file should be in the config directory with a name and return.

Your name will be replaced by a name and your database information will be constant. (NAME_DB for 'name')

a sample database file:

<?phpreturn [
    #Database Config
    'host'      => '127.0.0.1',
    'driver'    => 'mysql',
    'database'  => 'karmate',
    'username'  => 'root',
    'password'  => '1234',
    'charset'   => 'utf8',
    'collation' => 'utf8_general_ci',
    'prefix'    => ''
    ];

                        

you can use your database information as NAME_DB ['host'] if you need to do a database operation somewhere :)

And without forgetting, unlimited database information is free to constant.

'databaseConfig'         => array(
                            'name'  => 'database.php',
                            'name2' =>'anotherdb2.php' #Another db,
                            'name3' =>'anotherdb3.php' #Another db
                            'name3' =>'anotherdb4.php' #Another db
                            ....
                            ),
                        

see also

Language supported projects with Karmate

Config customizations Karmate is available for flexing to the end of the Flexible PHP Framework.

#TEMPLATE DIRECTORYS

Directory customizations

It would be unfair for you not to be free for directory names, which you will use in your projects when you have made so much beautiful.

#TEMPLATE DIRECTORYS
'controllers'            => 'controllers'        ,
'models'                 => 'models'             ,
'views'                  => 'views'              ,
'themes'                 => 'themes'             ,
'error_pages'            => 'error_pages'        ,
'autorun'                => 'autorun'            ,
'public'                 => 'public'			 ,
'lang'					 => 'lang'
];
                        

The controllers directory is the repository for your controller files. Access from the link can be made.

The models directory will contain the libraries you will use for your libraries, the directory you will be using. Cant access from the link.

Views directory view files you will have your files. Cant access from the link.

Themes directory css, js, image files etc. the files will be hosted. Access from link.

The error_pages directory is for keeping your error files. The error-coded file you created into it is used automatically. Sample 404.php file is run on 404 errors.

You can create optional autorun code inside the autorun directory :)

The public folder contains your uploads, user-defined files. Linkten is free to access.

lang directory maybe you want to use it :)

see also

Language supported projects with Karmate

Connect view file with Controller file #back to top

You should investigate later. #1

Automatic theme processing with View files.

You should investigate later. #2

Assign shortcuts to View and Controller files.

You should investigate later. #3

Use of model files.

It is very simple to access the View file with the controller file. All you need to do is use the 'FW:' tag to access all Framework libraries.

>> new FW: APP\View('aViewFileName'); <<
                                    

If you want to transfer a variable from the controller file:

$headerTransfers = [
                    'title' => 'My Project',
                    'desc'	=> 'unbelievable'
                    ];
>> new FW: APP\View('header', $headerTransfers); <<
                                

And you want to use the variables you transferred in the view file:

<head>
    <title>@/title/@ | @/desc/@</title>
</head>
                                

If you want to use php code in your view file:

>> echo "example"; <<
                                

or loops:

{if(@/title/@ == 'My Project'/}
Its my project
{elseif(@/title/@ == 'Your Project')/}
Its your project
{else/}
Who is this?
{endif/}
                                

also see:

Language supported projects with Karmate #back to top

Preparing websites with language support has always been troublesome. Karmate uses a simple but effective method in this regard.

root dir -> apps -> yourproject -> config -> config.php
                        

You specify in the config file

 default_lang 

variable that you specify is for you to choose your language to receive framework notifications. In addition, your visitor first displays this language.

But it is possible to allow your visitor to choose a different language.

Let's find out that we can detect the language of our visitors.

Creat a new controller

Try with browser:

Let's send language parameter with browser and try it.

Let's check the language output by preparing a model.

I create a new model file.

Edit controller

Re-access with Browser


How can I download a remote library?#back to top