Speed up your extension development using 5 classes only!

Be focused on your true core business!

Would you like to code your Joomla!'s extension 10 times faster?

How would your life change?

Interesting questions, isn't it?

Have a look:

This is a simple Joomla database query:


<?php
defined
('_JEXEC') or die('Restricted access');

// Get a db connection.
$db JFactory::getDbo();

// Create a new query object.
$query $db->getQuery(true);

// Select all records from the user profile table where key is "custom.".
// Order it by the ordering field.
$query->select('*');
$query->from($db->quoteName('#__user_profiles'));
$query->where($db->quoteName('profile_key') . ' = '$db->quote('custom'));
$query->order('ordering ASC');

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects.
$results $db->loadObjectList();

171 digits (comments excluded)

Now have a look at the same query using BPLibrary:


<?php
defined
('_JEXEC') or die('Restricted access');

$results BpDb::getList(   '#__user_profiles'
                            
, array('profile_key'=>'custom')
                            , array(
'order'=>array('ordering'=>'ASC')));

115 digits only!

56 digits shorter!

Nice, isn't it?

Now, how many query do you write in your extensions?

10? 56 * 10 = 560 digits shorter

30? 56 * 30 = 1680 digits shorter

50? 56 * 50 = 2800 digits shorter

Start thinking about what you will do with the time you save.

 

And this is just to start!

 

What happens if the core CMS functions change name or syntax? How much time did you spend just to update your extensions? And we know how often it happens, don't we?

Including BPLibrary in your extensions all you will need is just to update the library. 😳

 

And the best is still to come.

With BPLibrary you Code As You Think (CAYT).

 

Have a look at the most common thing you do developing a Joomla! extension. Use Bp class.

Want to add a css stylesheet in the header? use addCss


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::addCss($my_css_document);

 

Want to add a javascript file in the header? use addJava


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::addJava($my_java_document);

 

Want to add a javascript code directly in the header? use addJavaCode


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::addJavaCode($java_code_snippet);

 

Want to use a model from anywhere? use getModel


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::getModel($model_name);

 

Want to use another component's model? still use getModel


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::getModel($model_name$component_name);

  

Has the model another prefix? still use getModel


<?php
defined
('_JEXEC') or die('Restricted access');

Bp::getModel($model_name$component_name$model_prefix);




Nice, huh?


Let's go deeper, still using Bp class:

Want to get a variable value by searching anywhere? use get


<?php
defined
('_JEXEC') or die('Restricted access');

// search for 'my_var' variable. returns null if not found
Bp::get('my_var');

  

Want to get a variable value or a default value if not found? still use get


<?php
defined
('_JEXEC') or die('Restricted access');

// search for 'my_var' variable. returns 'default_value' if not found
Bp::get('my_var''default_value');

  

Want to get a variable value and filter it? still use get


<?php
defined
('_JEXEC') or die('Restricted access');

// search for 'my_var' variable and filter it as integer. returns 'default_value' if not found
Bp::get('my_var''default_value''int');

  

Want to get a variable by searching only in a specific superglobal? still use get


<?php
defined
('_JEXEC') or die('Restricted access');

// search for 'my_var' variable in post superglobal only and filters it as integer. returns 'default_value' if not found
Bp::get('my_var''default_value''int''post');

  

Use text placeholders with replace


<?php
defined
('_JEXEC') or die('Restricted access');

// set a template text
$template "the {KEY1} {KEY2} on {KEY3} {KEY4}";

// set all keys / text pairs
$replace = array();
$replace['KEY1'] = 'cat';
$replace['KEY2'] = 'is';
$replace['KEY3'] = 'the';
$replace['KEY4'] = 'table';

// use replace method
$text Bp::replace($replace);

// $text now is 'the cat is on the table'

  

What if you have placeholders in squares? still use replace


<?php
defined
('_JEXEC') or die('Restricted access');

// set a template text
$template "the [KEY1] [KEY2] on [KEY3] [KEY4]";

// set all keys / text pairs
$replace = array();
$replace['KEY1'] = 'cat';
$replace['KEY2'] = 'is';
$replace['KEY3'] = 'the';
$replace['KEY4'] = 'table';

// use replace method
$text Bp::replace($replace'square');

// $text now is 'the cat is on the table'

  

What if you have placeholders mixed in squares and braces? still use replace


<?php
defined
('_JEXEC') or die('Restricted access');

// set a template text
$template "the [KEY1] {KEY2} on [KEY3] {KEY4}";

// set all keys / text pairs
$replace = array();
$replace['KEY1'] = 'cat';
$replace['KEY2'] = 'is';
$replace['KEY3'] = 'the';
$replace['KEY4'] = 'table';

// use replace method
$text Bp::replace($replace'both');

// $text now is 'the cat is on the table'

  

While coding, how many times you need to check the content of a variable? use vd


<?php
defined
('_JEXEC') or die('Restricted access');

/*
// NO MORE
echo '<pre>';
var_dump($my_var_to_check);
echo '</pre>';
*/

// NOW JUST vd
Bp::vd($my_var_to_check);

  

Nice?

You want to add custom system message here and there, don't you? use addMex


<?php
defined
('_JEXEC') or die('Restricted access');

/*
// NO MORE
$application = JFactory::getApplication();
$application->enqueueMessage('Message');
*/

// NOW JUST addMex - default is 'notice' type
Bp::addMex('Message');

58 digits shorter! And you do all the most common things with the same class: Bp

Don't waste your time to remember (or worse to search for) the right class / function / method / changed / so / many / times / documentation / in / pages / not / updated / or / worse / no / more / available anymore! Spend your time to rise money instead!

 

You develop multilingual extensions, don't you?

Have a look at what the method txt can do for you: use txt


<?php
defined
('_JEXEC') or die('Restricted access');

// Let's say you have in language file:
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH="Month"

// In your extension use
$month Bp::txt('MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH');

// $month is now 'Month'

What if you have plurals?

The only thing you have to do is to add the number to the method call: use txt


<?php
defined
('_JEXEC') or die('Restricted access');

// Let's say you have in language file:
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH="Month"
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH_MORE="Months"

// In your extension use
$month Bp::txt('MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH');

// $month is now 'Months'

You can even customize dynamically the translation text: use txt


<?php
defined
('_JEXEC') or die('Restricted access');

// Let's say you have in language file:
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH="Month"
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH_MORE="%d Months"

// In your extension use
$month Bp::txt('MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH');

// $month is now '4 Months'

Some languages have different plurals rules.
Let your customer customize their language translation file for specific plural!

Say the user's language requires specific rule for 4 units. All the user has to do is to add the appropriate key to its language file (or, even better, to its language's override file)


<?php
defined
('_JEXEC') or die('Restricted access');

// Let's say you have in language file:
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH="Month"
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH_4="the %dth month of the year is April"
// MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH_MORE="%d Months"

// In your extension use
$month Bp::txt('MY_COMPONENT_TEXT_LANGUAGE_KEY_MONTH');

// $month is now 'the 4th month of the year is April'

Don't lie, you are thinking we have some refuse in our example as it's always the same method call, aren't you?

That's the power!
Let the method do the dirty work!

Nice, huh?

And this is only the apex of the iceberg!

Have a look at the example pages: examples

Download