PHP Class converter to namepaces.

Last update: Sep 9, 2021

Namespacer

This tool will assist you in taking older underscore/prefix spaced code and will namespace it as best as it can, and also make the files and class names ZF/PEAR compatible.

This two step command will first scan files and produce a map. You can then view or edit the file before moving onto the second step. The second step does the actual transformation. These transformations will be done in place, so it is best to either do this in a separate copy of the code, or on top of a git repository where you can easily reset --hard if you need to.

Download: https://github.com/ralphschindler/Namespacer/blob/master/namespacer.phar?raw=true

  • First, create a map file:

    namespacer.phar map --mapfile types.php --source path/to/src
    
  • Second, transform the types located in the map file:

    namespacer.phar transform --mapfile types.php
    

GitHub

https://github.com/ralphschindler/Namespacer
You might also like...

JavaScript to JQuery Converter

JQuery To Javascript Converter for helping to removing JQuery on websites.

May 3, 2022

A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class

Changelog Update support for Laravel 6 & phpunit 8 Update composer.json Upgrade to PSR-4 add parameter newline, delimiter, enclosure, and escape to ex

Mar 28, 2022

Exploiting and fixing security vulnerabilities of an old version of E-Class. Project implemented as part of the class YS13 Cyber-Security.

Open eClass 2.3 Development of XSS, CSRF, SQLi, RFI attacks/defences of an older,vulnerable version of eclass. Project implemented as part of the clas

Apr 23, 2022

A full-scale PHP sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code

A full-scale PHP sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code

A full-scale PHP 7.4+ sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code. It also utilizes FunctionParser to di

May 13, 2022

Simple utility and class library for generating php classes from a wsdl file.

wsdl2phpgenerator Simple WSDL to PHP classes converter. Takes a WSDL file and outputs class files ready to use. Uses the MIT license. Announcement: We

May 19, 2022

PHP class to generate bookmarklets from Javascript code

Bookmarklet Gen Convert readable Javascript code into bookmarklet links Features removes comments compresses code by removing extraneous spaces, but n

May 4, 2022

A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser to prevent sandboxed code from running unsafe code.

A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser to prevent sandboxed code from running unsafe code.

##DEPRECATED: The PHPSandbox project has transfered to Corveda/PHPSandbox and will be actively maintained there. This branch is no longer being active

Apr 5, 2022

GifCreator is a PHP class that creates animated GIF from multiple images

================================ GifCreator ================================ GifCreator is a PHP class to create animated GIF from multiple images For

Apr 7, 2022

GifFrameExtractor is a PHP class that separates all the frames (and their duration) of an animated GIF

================================ GifFrameExtractor ================================ GifFrameExtractor is a PHP class that separates all the frames (an

Mar 6, 2022

A Simple Logging Class For PHP

KLogger: Simple Logging for PHP A project written by Kenny Katzgrau and Dan Horrigan. About KLogger is an easy-to-use PSR-3 compliant logging class fo

May 16, 2022

Optimizes class loading performance by generating a single PHP file containing all of the autoloaded files.

Optimizes class loading performance by generating a single PHP file containing all of the autoloaded files.

Class Preloader for PHP This tool is used to generate a single PHP script containing all of the classes required for a specific use case. Using a sing

May 15, 2022

PHP routing class. Lightweight yet flexible. Supports REST, dynamic and reversed routing.

AltoRouter AltoRouter is a small but powerful routing class, heavily inspired by klein.php. $router = new AltoRouter(); // map homepage $router-map(

May 25, 2022

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Motto: "Every business should have a detection script to detect mobile readers." About Mobile Detect is a lightweight PHP class for detecting mobile d

May 28, 2022

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

May 19, 2022

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

May 24, 2022

🕷 CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent

🕷 CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent

crawlerdetect.io About CrawlerDetect CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent and http_from header. Current

May 27, 2022

Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

NO LONGER MAINTAINED!!! Image Cache v. 1.0.0 Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file,

Mar 13, 2022

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs

PHP Curl Class: HTTP requests made easy PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. Installation Requirements Quic

May 21, 2022

Utility PHP class to simplify interacting with persistent dismissible WordPress notices, promos, and banners

Persistent Dismissible A class for encapsulating the logic required to maintain a relationship between the database, a dismissible UI element (with an

Dec 19, 2021
Comments
  • 1. Zend\Code\Exception\RuntimeException No tokens were provided

    Tried using this library, but got this error each time.

    $ php namespacer.phar map --mapfile map.php --source .
    ======================================================================
       The application has thrown an exception!
    ======================================================================
     Zend\Code\Exception\RuntimeException
     No tokens were provided
    ----------------------------------------------------------------------
    phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-code/Zend/Code/Scanner/TokenArrayScanner.php:2
    #0 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-code/Zend/Code/Scanner/TokenArrayScanner.php(2): Zend\Code\Scanner\TokenArrayScanner->scan()
    #1 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/src/Namespacer/Model/Mapper.php(2): Zend\Code\Scanner\TokenArrayScanner->getClassNames()
    #2 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/src/Namespacer/Model/Mapper.php(2): Namespacer\Model\Mapper->getMapDataForFile('/Users/JT/Sites...')
    #3 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/src/Namespacer/Controller/Controller.php(2): Namespacer\Model\Mapper->getMapDataForDirectory('.')
    #4 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-mvc/Zend/Mvc/Controller/AbstractActionController.php(2): Namespacer\Controller\Controller->createMapAction()
    #5 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
    #6 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-eventmanager/Zend/EventManager/EventManager.php(2): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
    #7 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-eventmanager/Zend/EventManager/EventManager.php(2): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #8 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-mvc/Zend/Mvc/Controller/AbstractController.php(2): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #9 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-mvc/Zend/Mvc/DispatchListener.php(2): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Console\Request), Object(Zend\Console\Response))
    #10 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
    #11 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-eventmanager/Zend/EventManager/EventManager.php(2): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
    #12 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-eventmanager/Zend/EventManager/EventManager.php(2): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #13 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/vendor/zendframework/zend-mvc/Zend/Mvc/Application.php(2): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #14 phar:///Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar/namespacer.php(2): Zend\Mvc\Application->run()
    #15 /Users/JT/Sites/dsgnwrks.pro/wp-content/mu-plugins/cmb2/namespacer.phar(7): require('phar:///Users/J...')
    #16 {main}
    ======================================================================
       Previous Exception(s):
    ======================================================================
    
    Reviewed by jtsternberg at 2015-08-03 13:15
This library provides a way of avoiding usage of constructors when instantiating PHP classes.

Instantiator This library provides a way of avoiding usage of constructors when instantiating PHP classes. Installation The suggested installation met

May 21, 2022
HTML to PDF converter for PHP

Dompdf Dompdf is an HTML to PDF converter At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is

May 28, 2022
Unit converter and calculator for php

Unit converter and calculator This library uses the awesome lisachenko/z-engine to allow mathematical operations on objects, allowing to do stuff like

Apr 8, 2022
Arbitrary number base converter.

Numbase Easily convert numbers between arbitrary bases and symbol sets. Installation This library is available on Packagist as thunderer/numbase. It r

Mar 2, 2021
An ANSI to HTML5 converter

ANSI to HTML5 Converter This small library only does one thing: converting a text containing ANSI codes to an HTML5 fragment: require_once __DIR__.'/v

May 10, 2022
Laravel: Data to Monthly Converter

Laravel: Data to Monthly Converter Using this package you will be able to converts your collection using a timestamp field to order data monthly or ye

May 11, 2022
UUID <=> ULID bidirectional converter

uuid-ulid-converter UUID <=> ULID bidirectional converter Installing composer require mpyw/uuid-ulid-converter API static string Converter::uuidToUli

Mar 27, 2022
Google-like values converter

Google-like values converter. Support for different types of conversions, for examples: 1 kilometer -> meters 1 dollar -> THB 1 kilogram -> meters ...

Nov 4, 2021
PHPUnit to Pest Converter

PestConverter PestConverter is a PHP library for converting PHPUnit tests to Pest tests. Before use Before using this converter, make sure your files

May 7, 2022
A full-featured home hosted Cloud Drive, Personal Assistant, App Launcher, File Converter, Streamer, Share Tool & More!
A full-featured home hosted Cloud Drive, Personal Assistant, App Launcher, File Converter, Streamer, Share Tool & More!

A Fully Featured home-hosted Cloud Storage platform and Personal Assistant that Converts files, OCR's images & documents, Creates archives, Scans for viruses, Protects your server, Keeps itself up-to-date, and Runs your own AppLauncher!

May 15, 2022