The foundation of the Sledgehammer Framework

Installs: 1 033

Dependents: 11

Stars: 3

Watchers: 5

Forks: 2

Open Issues: 0

15.08.0 2015-09-08 11:54 UTC


Sledgehammer Core facilitates the foundation of the Sledgehammer Framework.

Build Status



  • Framework initialisation (+ Module detection & initialisation)
  • Debugging, error-reporting and profiling functionality.
  • A collection of global functions (that should be included in PHP, imho)

Outside the scope

  • MVC & Helpers focussed on html generation.
  • ORM


  • Autoloader : Detects classes and interfaces in any php file and load them when needed. no more includes.
  • ErrorHandler : An error reporting solution.
  • Object : A more strict base class with improved error messages.
  • Dump/dump() : A colorfull var_dump, with copy-pastable array format.
  • Database : PDO Database class enhanced with logging/profiling and improved error/warning detection.
  • Sql : Generating complex queries in a chainable.
  • Collection : Enhanced Array/Iterator handling.
  • Text : Chainable UTF-8 string functions.
  • Url : Read and generate urls in a OOP style.
  • Cache/cache() : Easy caching api using closures.
  • Json : Reliable JSON encoding and decoding.
  • DebugR : Sending debugging information alongside XMLHttpRequests.
  • more...


  • ENVIRONMENT : The current environment ("development", "staging" or "production") based on $_SERVER['APPLICATION_ENV']
  • E_MAX : Maximum errorlevel, because E_ALL doesn't include E_STRICT messages in php 5.3.
  • PATH : The absolute (server)path of the project folder
  • TMP_DIR : The absolute (server)path of the tmp/cache folder
  • APP_DIR : The absolute (server)path of the application folder
  • MODULE_DIR : The absolute (server)path of the sledgehammer (module) folder


Use composer to install sledgehammer modules.

$ composer.phar require sledgehammer/core:*

Just include('vendor/autoload.php'); and the Sledgehammer Framework (and other installed composer libraries) can be used.

You can try the dump function: dump($var); to check if the installation is successful.

As an added bonus, all errors, warnings and notices are now handled by the Sledgehammer ErrorHandler.


If no ENVIRONMENT constant has been defined, Sledgehammer will look at the value of $_SERVER['APPLICATION_ENV']. If this isn't found either, the default fallback is "production"

You can set the APPLICATION_ENV by adding SetEnv APPLICATION_ENV development to the .htaccess or httpd.conf:

You can force an environment by defining the ENVIRONMENT constant before including "vendor/autoload.php"

The errorhandler sends error reports per email to the address configured in \Sledgehammer\Framework::$errorHandler->email. By default the emailaddress specified in $_SERVER['SERVER_ADMIN'] is used.

Static files

Serve static files from modules by adding a line to your rewrite/index.php.



If your application already uses an autoloader, you can configure the AutoLoader to suppress warnings when a class isn't found.

\Sledgehammer\Framework::$autoloader->standalone = false;