How to install composer

What is Composer

A composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

System Requirements

Composer requires PHP 5.3.2+ to run. A few sensitive PHP settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.

To install packages from sources instead of simple zip archives, you will need git, svn, fossil or hg depending on how the package is version-controlled.

Composer is multi-platform and we strive to make it run equally well on Windows, Linux, and macOS.

Installation Instruction

1) Use PHP to download the composer installer, place it in the current directory, and name it composer-setup.php
2) Use PHP to check the hash of the file you downloaded and compare it to the known value of the hash. You can always find the current value of the hash for the installer on the Composer Public Keys / Signatures page.
3) Run the setup program to install the composer. This does more than just download the latest copy of the composer, it also sets up your local ~/.composer directory. This will install the composer into the current directory. You can add the –install-dir=DIR to specify where you want the composer installed. You can also specify –filename=composer to change the installed filename. You can use anything you like that doesn’t already exist in your specified directory, you don’t have to use the name composer. This is a great way to get rid of the .phar at the end of the name if you don’t like it.
4) Use PHP to remove the installer from the current directory.

To install composer for PHP you use PHP to download the installer, set a few options, and then actually perform the install.

Follow these steps to install the composer.

How to install Node.js on WHM server or cPanel

In this post i will explain how to install Node.js on your hosting server.

Node.js is a JavaScript runtime and uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. You can check more information on their official website https://nodejs.org/en.

To install Node.Js open SSH and use third-party tool (Like Putty) to run commands or use Terminal provided on WHM or cPanel servers.

Now run below listed commands one by one to install Node.Js on your hosting server.

1) #cd /usr/local/src

2) #wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz

3) #tar -zxvf node-v0.10.26.tar.gz

4) #cd node-v0.10.26

5) #./configure –prefix=/usr/local

6) #make

7) #make install

That’s is the whole steps to install the Node.js on the WHM server or cPanel.

To check the node.js version run below command.

#node -v

After running this command you will get output like this

v0.10.26

To install any module of Node.Js run command like this

# npm install MODULE_NAME

Hope this will help. Enjoy!

How to get a YouTube video Image or Thumbnail

In this post you will learn how to get you tube video images and thumbnails.

There are various method to get Images or Thumbnails like using url manually or getting it from API. Below you will see both methods of getting this information.

Method 1.

Getting images manually using URL.

Each YouTube video has 4 generated images. They are predictably formatted as follows:

https://img.youtube.com/vi/insert-youtube-video-id-here/0.jpg
https://img.youtube.com/vi/insert-youtube-video-id-here/1.jpg
https://img.youtube.com/vi/insert-youtube-video-id-here/2.jpg
https://img.youtube.com/vi/insert-youtube-video-id-here/3.jpg

The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

https://img.youtube.com/vi/insert-youtube-video-id-here/default.jpg

For the high quality version of the thumbnail use a url similar to this:
https://img.youtube.com/vi/insert-youtube-video-id-here/hqdefault.jpg

There is also a medium quality version of the thumbnail, using a url similar to the HQ:
https://img.youtube.com/vi/insert-youtube-video-id-here/mqdefault.jpg

For the standard definition version of the thumbnail, use a url similar to this:
https://img.youtube.com/vi/insert-youtube-video-id-here/sddefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:
https://img.youtube.com/vi/insert-youtube-video-id-here/maxresdefault.jpg

All of the above urls are available over http too.

Additionally, the slightly shorter hostname i3.ytimg.com works in place of img.youtube.com in the example urls above.

Method 2.

You can use YouTube Data API to retrieve video thumbnails, caption, description, rating, statistics and more. API version 3 requires a key*. Obtain the key and create a videos: list request:

https://www.googleapis.com/youtube/v3/videos?key=YOUR_API_KEY&part=snippet&id=VIDEO_ID

Example PHP Code

Output

NOTE: Not only that you need a key, you might be asked for billing information depending on the number of API requests you plan to make. However, few million requests per day are free.

You can also user CURL method to get this output.

How to create logs in php

Many times we need to create logs in our Web Applications to track any certain Errors or Response. We just need to put a bunch of code where you want to Create a log. In this post you will learn how to create logs using Php Code.

This code will check for the filename. If its available then it will write into the file and if code does not find the file it will create the new for of given name and will write the Logs. You can also use this code in any function you want.

HTML helper in codeigniter

HTML Helper

The HTML Helper file contains functions that assist in working with HTML.

Loading this Helper

This helper is loaded using the following code:

Available Functions

The following functions are available:

heading([$data = ”[, $h = ‘1’[, $attributes = ”]]])

Parameters:
  • $data (string) – Content
  • $h (string) – Heading leve
  • $attributes (mixed) – HTML attributes
  • Returns:HTML heading tag
    Return type:string

    Lets you create HTML heading tags. The first parameter will contain the data, the second the size of the heading.

    Examples:

    The above would produce:

    Welcome!

    Additionally, in order to add attributes to the heading tag such as HTML classes, ids or inline styles, a third parameter accepts either a string or an array:

    The above code produces:

    img([$src = ”[, $index_page = FALSE[, $attributes = ”]]])

    Parameters:
  • $src (string) – Image source data
  • $index_page (bool) – Whether to treat $src as a routed URI string
  • $attributes (array) – HTML attributes
  • Returns:HTML image tag
    Return type:string

    Lets you create HTML tags. The first parameter contains the image source. Example:

    There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config[‘index_page’] added to the address it creates. Presumably, this would be if you were using a media controller:

    Additionally, an associative array can be passed to the img() function for complete control over all attributes and values. If an alt attribute is not provided, CodeIgniter will generate an empty string.

    Example:

    link_tag([$href = ”[, $rel = ‘stylesheet'[, $type = ‘text/css'[, $title = ”[, $media = ”[, $index_page = FALSE]]]]]])

    Parameters:
  • $href (string) – What are we linking to
  • $rel (string) – Relation type
  • $type (string) – Type of the related document
  • $title (string) – Link title
  • $media (string) – Media type
  • $index_page (bool) – Whether to treat $src as a routed URI string
  • Returns:HTML link tag
    Return type:string

    Lets you create HTML tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page.

    index_page is a boolean value that specifies if the href should have the page specified by $config[‘index_page’] added to the address it creates.

    Example:

    Further examples:

    Additionally, an associative array can be passed to the link() function for complete control over all attributes and values:

    ul($list[, $attributes = ”])

    Parameters:
  • $list (array) – List entries
  • $attributes (array) – HTML attributes
  • Returns:HTML-formatted unordered list
    Return type:string

    Permits you to generate unordered HTML lists from simple or multi-dimensional arrays. Example:

    The above code will produce this:

    Here is a more complex example, using a multi-dimensional array:

    The above code will produce this:

    ol($list, $attributes = ”)

    Parameters:
  • $list (array) – List entries
  • $attributes (array) – HTML attributes
  • Returns:HTML-formatted ordered list
    Return type:string

    Identical to ul(), only it produces the

      tag for ordered lists instead of

        .

        meta([$name = ”[, $content = ”[, $type = ‘name'[, $newline = “n”]]]])

        Parameters:
      • $name (string) – Meta name
      • $content (string) – Meta content
      • $type (string) – Meta type
      • $newline (string) – Newline character
      • Returns:HTML meta tag
        Return type:string

        Helps you generate meta tags. You can pass strings to the function, or simple arrays, or multidimensional ones.

        Examples:

        doctype([$type = ‘xhtml1-strict’])

        Parameters:
      • $type (string) – Doctype name
      • Returns:HTML DocType tag
        Return type:string

        Helps you generate document type declarations, or DTD’s. XHTML 1.0 Strict is used by default, but many doctypes are available.

        Example:

        The following is a list of doctype choices. These are configurable, and pulled from application/config/doctypes.php

        Document typeOptionResult
        XHTML 1.1xhtml11<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd“>
        XHTML 1.0 Strictxhtml1-strict<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
        XHTML 1.0 Transitionalxhtml1-trans<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
        XHTML 1.0 Framesetxhtml1-frame<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd“>
        XHTML Basic 1.1xhtml-basic11<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML Basic 1.1//EN” “http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd“>
        HTML 5html5<!DOCTYPE html>
        HTML 4 Stricthtml4-strict<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd“>
        HTML 4 Transitionalhtml4-trans<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd“>
        HTML 4 Framesethtml4-frame<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd“>
        MathML 1.01mathml1<!DOCTYPE math SYSTEM “http://www.w3.org/Math/DTD/mathml1/mathml.dtd“>
        MathML 2.0mathml2<!DOCTYPE math PUBLIC “-//W3C//DTD MathML 2.0//EN” “http://www.w3.org/Math/DTD/mathml2/mathml2.dtd“>
        SVG 1.0svg10<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.0//EN” “http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd“>
        SVG 1.1 Fullsvg11<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd“>
        SVG 1.1 Basicsvg11-basic<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1 Basic//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd“>
        SVG 1.1 Tinysvg11-tiny<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1 Tiny//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd“>
        XHTML+MathML+SVG (XHTML host)xhtml-math-svg-xh<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN” “http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd“>
        XHTML+MathML+SVG (SVG host)xhtml-math-svg-sh<!DOCTYPE svg:svg PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN” “http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd”>
        XHTML+RDFa 1.0xhtml-rdfa-1<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML+RDFa 1.0//EN” “http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd“>
        XHTML+RDFa 1.1xhtml-rdfa-2<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML+RDFa 1.1//EN” “http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd“>

        br([$count = 1])

        Parameters:
      • $count (int) – Number of times to repeat the tag
      • Returns:HTML line break tag
        Return type:string

        Generates line break tags (
        ) based on the number you submit. Example:

        The above would produce:

        Note
        This function is DEPRECATED. Use the native str_repeat() in combination with
        instead.

        nbs([$num = 1])

        Parameters:
      • $num (int) – Number of space entities to produce
      • Returns:A sequence of non-breaking space HTML entities
        Return type:string

        Generates non-breaking spaces ( ) based on the number you submit. Example:

        The above would produce:

        Note
        This function is DEPRECATED. Use the native str_repeat() in combination with   instead.

    Language helper in codeigniter

    Language helper

    The Language Helper file contains functions that assist in working with language files.

    Loading this Helper

    This helper is loaded using the following code:

    Available Functions

    The following functions are available:

    lang($line[, $for = ”[, $attributes = array()]])

    Parameters:
  • $line (string) – Language line key
  • $for (string) – HTML “for” attribute (ID of the element we’re creating a label for)
  • $attributes (array) – Any additional HTML attributes
  • Returns:The language line; in an HTML label tag, if the $for parameter is not empty
    Return type:string

    This function returns a line of text from a loaded language file with simplified syntax that may be more desirable for view files than CI_Lang::line().

    Examples:

    Number helper in codeigniter

    Number Helper

    The Number Helper file contains functions that help you work with numeric data.

    Loading this Helper

    This helper is loaded using the following code:

    Available Functions

    The following functions are available:

    byte_format($num[, $precision = 1])

    Parameters:
  • $num (mixed) – Number of bytes
  • $precision (int) – Floating point precision
  • Returns:Formatted data size string
    Return type:string

    Formats numbers as bytes, based on size, and adds the appropriate suffix.

    Examples:

    An optional second parameter allows you to set the precision of the result:

    Note
    The text generated by this function is found in the following language file: language//number_lang.php

    Path helper in codeigniter

    Path Helper

    The Path Helper file contains functions that permits you to work with file paths on the server.

    Loading this Helper

    This helper is loaded using the following code:

    Available Functions

    The following functions are available:

    set_realpath($path[, $check_existance = FALSE])

    Parameters:
  • $path (string) – Path
  • $check_existance (bool) – Whether to check if the path actually exists
  • Returns:An absolute path
    Return type:string

    This function will return a server path without symbolic links or relative directory structures. An optional second argument will cause an error to be triggered if the path cannot be resolved.

    Examples: