JQPhp Documentation

JQPhp is a simple and very flexible PHP library that can be used to quickly perform simple javascript calls directly via PHP.

Download Clone Via GitHub

Tired of having to include the boring <script></script> tags in the middle of your codes just because you want to do something simple such as displaying an alert or toggling the visibility of an html element?

Let's display a javascript alert in jquery

Javascript

  <script>
 $(document).ready(function(){   alert("This is an alert in javascript");  }); </script>

It's now possible to do the same thing in PHP. This time around, it's become very easy!

PHP

  $jqphp->Alert("This is an alert in PHP");

With this library, you can perform common javascript operations such as modifying the css definitions of html elements, performing client side redirections, toggling the visibility of elements, animating html elements and so on without ever having to type the script tags again!

Namespacing

The JQPhp library is made of classes which are categorized into various namespaces depending on their functionality or scope.

Namespace Location Description
JQPhp JQPhp.php This is the base namespace and is made up of class objects that are shared among the classes of other namespaces
JQPhp\Selector undefined Contains class objects that are shared amongst the classes of every other child namespace such as JQPhp\Selector\Attributes
JQPhp\Shared shared.php Contains objects that are required by the classes of the JQPhp\Selector namespace
JQPhp\Selector\Attributes JQPhp.Selector.Attributes.php Contains classes that impersonates the attribute selectors as the prefix, has, contains, startswith selectors in jquery.
JQPhp\Selector\Basics JQPhp.Selector.Basics.php the #ID, .Class, "*" (ALL) selectors are all basic selectors in jquery. This namespace contains classes that implements these selectors in PHP
JQPhp\Selector\Filters JQPhp.Selector.Filters.php this namespace contains classes that implements the filter selectors such as :odd, :header, :even and so on in PHP.

Enable

You can enable javascript by providing a valid url or file path location to either the minified or unminified jquery library in the constructor of this class

      /* ---------- Enabling Javascript directing via PHP -----------*/
        new JQPhp\Enable("path-to-jquerys-cdn-or-file-path-location.js");
      

Alert

This class emulates the javascript alert() object.

/* ---------- Showing An Alert -----------*/
  new JQPhp\Alert("Click The Cancel Button To Close This Alert");

Prefix

This class can be used to select every element that has an attribute that contains a particular value

        $prefix = new JQPhp\Prefix("a", "href", "#", new JQPhp\jquery());

      /* The example above selects all "a" element where their "href" attributes are equivalent to "#" */
/* the example below selects all "div" elements where the "id" attribute is equal to "projector" */ $prefix2 = new JQPhp\Prefix("div", "id", "projector", new JQPhp\jquery());

This class and every other classes in the JQPhp\Selector\Attributes Namespace contains three methods for changing the element, attribute or value that are declared in the constructor. The methods are: setElement($value), setAttribute($value), setValue($value).
Other classes in this namespace includes StartsWith Has Contains Equals EndsWith NotEqual and they can all be instantiated the same way the Prefix class is instantiated

  1. Email — samueladeshina73@gmail.com (samueladeshina73 at gmail dot com)
  2. Facebook https://www.facebook.com/samuel.adeshina.779
  3. Twitter https://twitter.com/SamuelAdeshina6
  4. GitHub https://github.com/Samshal
  5. Google+ https://plus.google.com/+SamuelAdeshina73
  6. LinkedIn

Thanks for checking out this package. Once again, I'ld love any feedbacks from you guys. I'm open to criticisms, suggestions and ready to answer your questions.