yfix

Yf framework development blog

[new] db migrations ready to be used

Posted by yfix on 2014-10-22
Posted in: core, howto, new feature, yf. Tagged: core, db, migrations, yf. Leave a comment

Recently I’ve completed YF db migrations functionality.
Source located here:
https://github.com/yfix/yf/blob/master/classes/db/yf_db_migrator.class.php

There are console helpers:


yf db:migrate compare
yf db:migrate generate
yf db:migrate create
yf db:migrate apply
yf db:migrate list
yf db:migrate dump

General commands:
* compare – will output differencies between current project db structure and expected php_sql db structure, stored in files inside framework and project. Computes differencies in:
tables, columns, indexes, foreign keys. Report about missing or new items and about changed items too.
* generate – will output internal migration commands, not writing anything to disk, useful to figure out how created migration can look like
* create – create new migration file into disk, based on compare result. Usually store file into APP_PATH/share/db/migrations/%new_migration_file%.php.
This method useful to store changes into database for future applying on other hosts.
* apply – apply selected migration into project database. Useful for applying database changes in controlled and repeatable manner.
* list – list available migrations to apply
* dump – dump current database structure into disk into sql_php files.

[new] function wildcard_compare()

Posted by yfix on 2014-10-22
Posted in: core, new feature, yf. Tagged: core, functions, yf. Leave a comment

I’ve added function wildcard_compare($wildcard, $string) into YF framework, which uses php built-in fnmatch() function, which is fast and not using regexps.
There is support for these patterns:
“*” – no or any number of symbols
“?” – exactly one symbol
“[abc]” – one of symbols passed inside square brackets

YF function wildcard_compare() differs from native fnmatch(): it can accept array of wildcards and if any of them matched – then overall return true.

Examples:


wildcard_compare('regex are * useful', 'regex are always useful')

Function source:
https://github.com/yfix/yf/blob/master/share/functions/yf_common_funcs.php#L397

Unit tests (also examples):
https://github.com/yfix/yf/blob/master/.dev/tests/unit/functions/function_wildcard_compare.Test.php

forked repos and cdn.rawgit

Posted by yfix on 2014-10-16
Posted in: yf. Leave a comment

List of lately used repositories:

https://github.com/yfix/Justified-Gallery
https://github.com/yfix/jQuery-File-Upload
https://github.com/yfix/jQuery-Mask-Plugin
https://github.com/yfix/fullcalendar
https://github.com/yfix/bootstrap-maxlength
https://github.com/yfix/blueimp-gallery

When in develop mode, you can conenct resources from github repository like this:
(note missing “/blob/” in path)
http://cdn.rawgit.com/yfix/bootstrap-maxlength/master/src/bootstrap-maxlength.js
instead of original url:
https://github.com/yfix/bootstrap-maxlength/blob/master/src/bootstrap-maxlength.js

git subsplit howto

Posted by yfix on 2014-10-16
Posted in: yf. Leave a comment

Automate and simplify the process of managing one-way read-only subtree splits.

Git subsplit relies on subtree being available. If is not available in your version of git (likely true for versions older than 1.7.11) please install it manually from here:
https://github.com/dflydev/git-subsplit

Install
git-subsplit can be installed and run standalone by executing git-subsplit.sh directly.
git-subsplit can also be installed as a git command by:
./install.sh

Example of usage:
https://github.com/laravel/framework/blob/4.2/build/illuminate-split-full.sh


git subsplit init git@github.com:laravel/framework.git
git subsplit publish src/Illuminate/Auth:git@github.com:illuminate/auth.git
git subsplit publish src/Illuminate/Cache:git@github.com:illuminate/cache.git
git subsplit publish src/Illuminate/Config:git@github.com:illuminate/config.git
git subsplit publish src/Illuminate/Console:git@github.com:illuminate/console.git
git subsplit publish src/Illuminate/Container:git@github.com:illuminate/container.git
git subsplit publish --heads="master" src/Illuminate/Contracts:git@github.com:illuminate/contracts.git
git subsplit publish src/Illuminate/Cookie:git@github.com:illuminate/cookie.git
git subsplit publish src/Illuminate/Database:git@github.com:illuminate/database.git
git subsplit publish src/Illuminate/Encryption:git@github.com:illuminate/encryption.git
git subsplit publish src/Illuminate/Events:git@github.com:illuminate/events.git
git subsplit publish src/Illuminate/Exception:git@github.com:illuminate/exception.git
git subsplit publish src/Illuminate/Filesystem:git@github.com:illuminate/filesystem.git
git subsplit publish src/Illuminate/Hashing:git@github.com:illuminate/hashing.git
git subsplit publish --heads="4.1 4.2" src/Illuminate/Html:git@github.com:illuminate/html.git
git subsplit publish src/Illuminate/Http:git@github.com:illuminate/http.git
git subsplit publish src/Illuminate/Log:git@github.com:illuminate/log.git
git subsplit publish src/Illuminate/Mail:git@github.com:illuminate/mail.git
git subsplit publish src/Illuminate/Pagination:git@github.com:illuminate/pagination.git
git subsplit publish src/Illuminate/Queue:git@github.com:illuminate/queue.git
git subsplit publish src/Illuminate/Redis:git@github.com:illuminate/redis.git
git subsplit publish --heads="4.1 4.2" src/Illuminate/Remote:git@github.com:illuminate/remote.git
git subsplit publish src/Illuminate/Routing:git@github.com:illuminate/routing.git
git subsplit publish src/Illuminate/Session:git@github.com:illuminate/session.git
git subsplit publish src/Illuminate/Support:git@github.com:illuminate/support.git
git subsplit publish src/Illuminate/Translation:git@github.com:illuminate/translation.git
git subsplit publish src/Illuminate/Validation:git@github.com:illuminate/validation.git
git subsplit publish src/Illuminate/View:git@github.com:illuminate/view.git
git subsplit publish src/Illuminate/Workbench:git@github.com:illuminate/workbench.git
rm -rf .subsplit/

Mine usage for splitting smarty distribution:


git subsplit init https://github.com/smarty-php/smarty.git
git subsplit publish distribution:git@github.com:yfix/smarty-distribution.git

resulting repository:
https://github.com/yfix/smarty-distribution

for update:


git subsplit update distribution:git@github.com:yfix/smarty-distribution.git
git subsplit publish distribution:git@github.com:yfix/smarty-distribution.git

[new feature] tpl if_func now supports multiple arguments

Posted by yfix on 2014-08-27
Posted in: core, docs, new feature, tpl, yf. Tagged: if_func, new feature, tpl, yf. Leave a comment

YF built-in template engine update:
if_func feature was upgraded today by providing ability to pass several variables instead of one.
This allows to create more complex conditions inside templates without need of additional actions.
Also, it is possible to change inner mulitple condition by adding “_or”, “_and” to function name.
This new addition also works will all other “if_func” features:
* custom functions
* negating of each comparison
* function shortcuts (“ok”, “not_ok”, “empty”, “isset”, etc)
* validation class usage

Lets go to examples:

// Imagine this kind of array:
$data = array(
  'name1' => '',
  'name2' => 'something',
  'name3' => '',
  'name4' => 'other',
  'name5' => '',
  'name6' => 'gggggg'
);
// and inside templates you can do now:
------------
{if_not_ok(name1,name3)}good{/if}
{if_not_ok(name1,name2)}bad{else}good{/if}
{if_or_ok(name1,name2)}good{/if}
{if_and_empty(name1,name3,name5)}good{/if} {if_and_not_empty(name2,name4,name6)}ok{/if}
{if_not_isset(name777,name888,name999)}good{/if}

As usual, there were added unit tests for this new feature:
https://github.com/yfix/yf/blob/master/.dev/tests/tpl/tpl_driver_yf_core.Test.php#L400

compatibility with hhvm and php5.6

Posted by yfix on 2014-08-19
Posted in: core, tests, yf. Tagged: core, hhvm, php5.6, tests, yf. Leave a comment

From now on all unit tests are passing on all important and modern php branches:

* 5.3.x (last tested on 5.3.28)

* 5.4.x (last tested on 5.4.31)

* 5.5.x (last tested on 5.5.18)

* 5.6 (tested on 5.6.0RC3, but I’m sure nothing big will be changed in release)

* HHVM 3.2

Important note is that HHVM is really faster when running with common website.

I see about 50% of speedup gain on real YF-based project.

Useful links:

* YF travis-ci (5 php branches tested too):  https://travis-ci.org/yfix/yf

* YF drone.io: https://drone.io/github.com/yfix/yf/latest

[new feature] tpl: foreach_exec

Posted by yfix on 2014-07-23
Posted in: core, new feature, tpl, yf. Tagged: core, foreach_exec, new feature, tpl, yf. Leave a comment

Say welcome to the new requested feature for templating engine: “foreach_exec”.
It is combination of the “foreach” iterator tag and “execute” class method calling tag.
It works by executing given argument as execute input and then iterates over result array.
As you can understand, called method should return array.
Aim of this tag is to leverage wrapping code amount and speed optimization to avoid
extra big arrays passing into templates by $replace array members.

Examples:

imagine result of the called method _class('unittest2')->_callme2 == array('k1' => 'v1', 'k2' => 'v2');
and now template code:

{foreach_exec(unittest2,_callme2)} _{_key}={_val}_ {/foreach_exec}
{foreach_exec(@object,_callme2)} _{_key}={_val}_ {/foreach_exec}
{foreach_exec(unittest2,_callme2)} _{_key}={_val}_ {elseforeach} no rows {/foreach_exec}

[new feature] tpl: @object and @action inside execute, and foreach_exec

Posted by yfix on 2014-07-23
Posted in: core, new feature, tpl, yf. Tagged: new feature, tpl, yf. Leave a comment

It is now possible to use magick @object (means $_GET[‘object’]) and @action (means $_GET[‘action’])
inside these template tags: {execute()}, {exec_cached()}, {exec_last()}, {foreach_exec()}.
Examples:

{execute(@object,some_method)}
{execute(@object,@action)}
{execute(@object,@action,k1=v2;k2=v2)}

{exec_cached(@object,some_method)}
{exec_cached(@object,@action)}
{exec_cached(@object,@action,k1=v2;k2=v2)}

{exec_last(@object,some_method)}
{exec_last(@object,@action)}
{exec_last(@object,@action,k1=v2;k2=v2)}

{foreach_exec(@object,some_method)} {_key}={_val} {/foreach_exec}
{foreach_exec(@object,@action)} {_key}={_val} {/foreach_exec}
{foreach_exec(@object,@action,k1=v2;k2=v2)} {_key}={_val} {/foreach_exec}

[new feature] tpl: extending functions and sections

Posted by yfix on 2014-07-22
Posted in: core, tpl, yf. Leave a comment

Welcome to the new feature of the YF templating engine: easy extending with callbacks and support for compiled and non-compiled modes.

Best explanation can be done with examples:

tpl()->add_function_callback('my_new_tpl_func', function($m, $replace, $stpl_name) {
    return '__'.$m['args'].'__';
});

{my_new_tpl_func(testme)}
#result: __testme__


tpl()->add_section_callback('my_new_tpl_section', function($m, $replace, $stpl_name) {
    return '__'.$m['args'].'__'.$m['body'].'__';
});

{my_new_tpl_section(k1=v1;k2=v2)} section_body {/my_new_tpl_section}
#result: __k1=v1;k2=v2__section_body__

More working examples can be seen inside unit tests for this feature here:

https://github.com/yfix/yf/blob/master/.dev/tests/tpl/tpl_driver_yf_extend.Test.php

As usual with latest new features, it is fully covered with unit tests, ensuring it will continue to work correctly in future, after any possible code refactoring attempts or php version changes or in differetn supported environments.

P.S. I remind that minimal PHP version for YF 1.x series is PHP 5.3 (which means no support in core for PHP 5.2 and earlier versions, even for templating engine).

Currently all unit tests successfully passing on 2 CI servers (drone.io and travis-ci) with 5.3, 5.4, 5.5 PHP latest branch versions

 

[new feature] tpl: if_funcs more aliases

Posted by yfix on 2014-07-22
Posted in: core, tpl, yf. Leave a comment

I just added several function aliases for the “if_funcs” feature inside templating engine.

Here is the full list of built-in aliases:

{if_empty()} / {if_not_empty()}
{if_isset()} / {if_not_isset()}
{if_true()} / {if_not_true()}
{if_false()} / {if_not_false()}
{if_ok()} / {if_not_ok()}

To remind: any other function can also be used in addition to these built-ins + validate class methods can be used too.

Also all these aliases available for the “elseif_funcs” feature like this:

{elseif_empty()} / {elseif_not_empty()}
{elseif_isset()} / {elseif_not_isset()}
{elseif_true()} / {elseif_not_true()}
{elseif_false()} / {elseif_not_false()}
{elseif_ok()} / {elseif_not_ok()}

Posts navigation

← Older Entries
Newer Entries →
  • Tags

    admin autoload blocks command line config console core create table db debug elseforeach events foreach_exec functions hhvm howto html https if_func migrations models new feature pager php php5.6 rewrite solution table tests tip tpl trick url validation yf
  • Recent Posts

    • [forms] render with templates
    • [tests] news: phpunit and codeception updates plus tests inside plugins
    • [new feature] html simple_table
    • [new feature] table now supports query builder object as sql input
    • yf framework assets usage
  • Meta

    • Register
    • Log in
    • Entries feed
    • Comments feed
    • WordPress.com
  • Archives

    • May 2016
    • November 2015
    • April 2015
    • February 2015
    • January 2015
    • December 2014
    • October 2014
    • August 2014
    • July 2014
    • June 2014
  • Categories

    • core
    • docs
    • howto
    • new feature
    • php
    • tests
    • tpl
    • trick
    • Uncategorized
    • utils
    • yf
Blog at WordPress.com.
yfix
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • yfix
    • Already have a WordPress.com account? Log in now.
    • yfix
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...