Download the PHP package abgit/myfw without Composer

On this page you can find all versions of the php package abgit/myfw. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package myfw

start

To use myfw all we need is to:

environment

myfw can be use at least in two environments: web or cron.

Web environment. When used in web environment we need to add get(), post(), or map() methods and a last run() at end. get(), post() or map() methods require at least two arguments: url to match and function to execute.

Cron environment. When used in cron environment we just need to add cron() methods. Cron method have two arguments, a string passed when executing cron by command line and function to execute.

To execute previous somearg cron, we only need to load file and specify somearg in command line: /bin/usr/php file.php somearg.

hello world

Let's create a simple example. Load a template file from our template directory, assign an url variable and display.

We need to inform myfw by using config() where are our template files so that render() can load them.

arguments

When using dynamic url's we must use variables and pass them in function. Example: display a news item based on url.

Because myfw is integrated with twig template engine, for previous example we need a templates/mytemplate.tpl file:

conditions

For each dynamic argument, we must add a pattern (eg: :id ), and a function argument (eg: function($id)). As good practice, we should always filter these arguments to control argument limits, sql injections and other problems. myfw has the setConditions() method that should describe all arguments and be placed on top before any action.

As alternative we can customize each action using conditions() method. Example:

mode

Most of times we have at least two environments: development (when our app is executed locally and some debugging is enabled) and production (when our app is executed on a remote server). This means that we need to assign distinct configuration options depending of our mode. To do this we only need to predefine config options using configureMode() for each mode and assign mode previously. Let's predefine development and production modes with different config settings:

There are at least 3 different ways to define mode to use:

group

Sometimes is useful to create url actions that have same prefix. Instead of specifying each action separately we can group them. This has several advantages: code becomes much cleaner and we can create global features that affect all sub actions.

form

On myfw, creating a form and process all logic flow is very easy. All we need is to define form behaviour and myfw will process everything. We should:

Note that, we don't need to create a new variable to handle form object, all internal myfw features are handle dynamically. Form object has lots of features to explore.

db

myfw database handling is very special. Every call is computed as a mysql stored procedure call. No hardcoded sql, no orm. All sql code is stored in mysql database and all we need is to invoke a procedure. Why stored procedures? From w3resouce.com:

All we need is to use db() and because we only want to retrieve one row, we can use findone() method to execute mysql findnewsid procedure. Because this procedure required an integer argument we must describe it including argument name nid and argument type int and include our argument values list in a array. Array values keys must match argument names definition. db methods always return call state (true if call is executed and a valid result was sent from database, false if call could not be completed or an invalid result was sent from database). Call result is stored in $result variable passed as first argument.

Additional methods

Example: get all elements (select):

Example: update or insert elements:

Combining a db and a form object

Here goes a simple example of how to combine a form object with a db object. We will create a form, get default values from database, assign db values to form elements and if form is submitted and form element values are valid we update our item in database.

i18n

Internationalization support is handle on php logic and template side. myfw uses php built-in gettext to handle translation with two functions _ and _n both on php and template side.

The main goal is to:

php examples

eg: outputs translated "hello world";

eg: if $name is david and $portal is domain.com, outputs translated "welcome david to domain.com".

eg: if $counter is 1 outputs "1 orange", if $counter is 5 outputs "lots of oranges";

eg: if $counter is 1 outputs "1 orange", if $counter is 5 outputs "5 oranges";

eg: if $counter is 1 outputs "1 orange in big tree", if $counter is 5 outputs "5 oranges in small trees";

template examples

Configuration

To init i18n support in myfw we need to setup i18n but setting translated files path for our LC_MESSAGES/lang/*.mo files by using i18n setPath() and optionally domain and codeset. Then, we only need to change language inside our actions.

i18n() supports session too. This way, we can use session value if exists:

In previous example we are changing language to en_US, use session value if available (instead of en_US) and save en_US in session for future use.

PoEdit settings

PoEdit is the best opensource software to handle all transation stuff. One of the most useful feature is to be able to extract strings to compute *.po files. All we need is to:

  1. add *.tpl extension in python settings. Go to File > Preferences > select Python > Edit > change List of extensions separated by semicolons to: *.py;*.tpl
    • create a new file: File > New; or open an existing: File > Open;
    • create keywords: Catalog > Properties... > click tab Sourced keywords > add _n:1,2 and add _n:1

rules

myfw has a built-in library to check patterns. These are just simple boolean methods that check an argument string and return true/false. These methods are integrated with form object when adding a form element so that we can check its value but we can use them alone too.

form integration

When adding a form element we can assign an array of rules as 3rd element. This is an array where each key is the rule name (rules method name) and value is the error message on an array with message and additional options.

stand alone

myfw rules available:

filters

Like the rules library, filters library can be used in three environments: form, template and standalone.

Form filters

when adding form elements. If form is submitted and valid, element values will be filtered when retrieving values.

Template filters

All filters available in myfilters library and native twig filters can be used in a template.

Standalone filters

Filters library can be invoked directly in php and used as standalone too:

filters available:

session

Session library contains simple methods to handle php $_SESSION. Instead of direct access we should use this simple library to store, delete, get session information.

cache

This is a simple library to handle apc or redis operations. Before access, set or delete a key make sure to setup enviroment with $app->config().

Cache engine has a built-in middleware architecture to cache actions. If we have action that is static almost the time, we can active iscache so that the cached version is displayed:

In previous example, if a /news/:id exists, all html will be displayed and no additional processing is done. If cache is empty or is first time, render() will automatically render template and store in cache so that next time /news/:id is invoked the cache version is displayed. Note that, iscache will work if:

cart

Cart library handles simple cart functions based on session library. There are some methods available like getItems, getTotalItems, getTotal, addItem, isItem, isItemValue, addExtra, getExtra, removeItem, updateItemProperty, getItemPropertyValue, checkItemProperty and clear.

logging

Logging is useful when we need to check internal app behavior. Setup logging level in your config and just log.

Currently, log uses an internal php print ouput, useful when using in a cron environment.

mailer

Mail engine is a very simple library to send emails. This library is integrated with rackspace mailgun api for delivery so need some additional config() params.

html support

Mailer engine supports templates. This means that we can assign a template to mailer library so that when we send an email will be computed an email based on that html template.

We need to create a template file in our templates directory, add a content tag that will be used by mailer engine to inject message and inform mailer about the template filename:

mymail.tpl file:

mail headers

If we need to specify additional mail headers we have a configuration parameter for that. Useful if we need to add a 'bcc' header:

urlFor

urlFor() is the method to create application URLs so that you can freely change route patterns without breaking your application. This method ca be used in php environment (this is the native slim method) or on template environment:

Just add a name to each action:

php environment example:

template environment example:

eg, if someitem variable containg xpto, both environments will compute /new/xpto/go url.

virustotal

Virus total is a google webservice to check files and websites based on some antivirus categorization. To use this lib we must set virustotal api key and use getInfo method to assign a website info.

transloadit

This library is the tranloadit webservice integration. All we need is to setup credentials and create an assembly using createAssembly() and/or request an assembly status info using request().

Transloadit createAssembly() just initialize the assembly. Then, transloadit webservice will process it and we need to retrieve results after some time. To do so, we need to use request() with our assembly url that we retrive in createAssembly $result.

brightcloud

Brightcloud is a webservice to categorize domains. Currently library retrieves a domain info. We need to setup credentials and infor getInfo() method.

--


All versions of myfw with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
slim/slim Version ^3.0
slim/twig-view Version 2.*
pavlakis/slim-cli Version 1.*
pavlakis/php-server-interface-middleware Version 0.*
bryanjhv/slim-session Version ~3.0
defuse/php-encryption Version 2.*
linusu/bitcoin-address-validator Version 0.*
aptoma/twig-markdown Version 3.*
michelf/php-markdown Version 1.*
league/html-to-markdown Version 4.*
ezyang/htmlpurifier Version 4.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package abgit/myfw contains the following files

Loading the files please wait ....