Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
simple introduction to Cement framework and its usage. Cement framework is mostly used for creating a command line application using python.

In version 2.6 of Cement you can initiate an app using with:
from cement.core.foundation import CementApp

with CementApp('myapp') as app:
app.run()

It hides complexieties in your application initiation. That is the above code would be something like below without using with:
from cement.core.foundation import CementApp

app = CementApp('myapp')
app.setup()
app.run()
app.close()

As you can see with procedure is more clear and straight forward with less code. I know it's silly to have an app like above, but that's just an introduction to the world of Cement.

To add logger to your framework you need to set log level in log.logging as below:
from cement.utils.misc import init_defaults
from cement.core.foundation import CementApp

defaults = init_defaults('myapp', 'log.logging')
defaults['log.logging']['level'] = 'DEBUG'
defaults['log.logging']['file'] = 'cementy.log'
defaults['log.logging']['to_console'] = True

with CementApp('myapp', config_defaults=defaults) as app:
app.run()
app.log.debug('This is debug')

init_defaults is used to setup logging. level sets the log level to DEBUG. file would write log data into cementy.log file.
By setting to_console param you can also write the data written to file into console too. So if you run your python application, a file would be created for logging and data will be printed out.

#python #cement #framework #logging #log #level #foundation
OnePHP a super simple and super lightweight PHP framework that works in just a few lines:

// index.php
require_once('src/OnePHP/one_framework.php');
$app = new \OnePHP\App();

$app->get('/:name',function( $name ) use ( $app ){//Action
echo "Hello $name";
});
$app->listen();


To install using composer:

composer create-project julces/oneframework

Why OnePHP:

1- Restful Routes

2- Easy and clean (GET, POST, PUT, DELETE...) Requests management

3- Restful Response with HTTP Status Code and custom Headers

4- PHP native Views

5- No dependencies, add extra libraries only when you need it.

#php #framework #onePHP