Giter VIP home page Giter VIP logo

pearify's Introduction

Pearify — Like Browserify, For PEAR compliance

Pearify is a tool to rewrite PSR-0 and PSR-4 PHP class names to the PEAR naming conventions. Pearify is based on the excellent PHP class-rewriting project by Michael Tibben.

Requirements

Pearify requires PHP version 5.4 or greater.

Installation

The simplest way to get Pearify is via Packagist. Simply add mridang/pearify to your composer JSON's list of requirements and run composer install.

About

Pearify relies heavily on Composer and works only on Composer-based projects. Pearify uses the classmap generated by Composer to get a list of PHP classes to be renamed.

Pearify requires that you have dumped the optimised autoload classmap so it can include the array of file paths. You can generate the classmap by invoking

composer dump-autoload --optimize

Running the aforementioned command, will generate a file called autoload_classmap.php in the vendor\composer directory. More information on the dump-autoload directive can be found at https://getcomposer.org/doc/03-cli.md#dump-autoload.

The classmap contains an exhaustive list of all the PHP classnames (including paths of dev dependencies) and the relative file paths. While this file contains classes from development dependencies as well, they are automatically excluded by Pearify.

Pearify reads your project's composer.json file to recursively deduce all the production dependencies of your project and only select classes from the classmap belonging to your project's production dependencies.

If you had a PHP class file called MyClass.php in the directory vendor/myname/myproject/

namespace MyName\MyProject;

use DateTime;

class MyClass {

    public function getDate() {
        return new DateTime("2014-10-20");
    }
}

It would be renamed and copied over to a file name lib\MyName\MyProject\MyClass.php

class MyName_MyProject_MyClass {

    public function getDate() {
        return new DateTime("2014-10-20");
    }
}

The original file is left untouched and the new file is created (or overwritten) with all the use and namespace statements removed.

Gotchas

Pearify has quite a few shortcomings. If you'd like to see support for one of the following added to Composer, please create a pull-request.

Authors

  • Mridang Agarwalla
  • Hannu Pölönen

Credits

  • Michael Tibben (@mtibben)

License

Pearify is licensed under the MIT License - see the LICENSE file for details.

pearify's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar mridang avatar supercid avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

supercid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.