Skip to content

Releases: htmlburger/wpemerge

0.17.0

16 Apr 17:17
Compare
Choose a tag to compare

Framework:

  • Added preliminary support for PHP 8 and PHP 8.1.
  • Added support for route handler references in the callable-like [ClassName::class, 'method'] format.
  • Added \App::views()->exists() and \App::views()->canonical() utility methods.
  • Added \App::router() utility method to access the router instance.
  • Added a new "namespace" root config option that is used as a default for all services (e.g. controllers, view composers, etc.).
  • Added WP_Filesystem as a service in the container under the WPEMERGE_APPLICATION_FILESYSTEM_KEY key.
  • Added the current route definition file and line to the debug screen on error.
  • Fixed config debug options not taking WP_DEBUG into account.
  • Fixed Flash::addToRequest() not respecting the current request key (#24, props @galengidman).

Starter Theme and Plugin:

  • Added support for Tailwind CSS v3.
  • Updated PostCSS to v8.
  • The release CLI command will now use a temporary directory and only produce a zip file, matching your working directory name.
  • Image and font directory structures are now preserved when compiled in dist/.
  • Vendor assets are now stored in a new dist/vendor/ directory when compiled.
  • Replaced PHP file functions usage with WordPress' WP_Filesystem, loaded from the container.
  • Improved ThemeCheck compliance.

App Core:

  • Improved script and style loading logic in all modes (development, hot, production with script debug off and on).
  • Replaced PHP file functions usage with WordPress' WP_Filesystem, loaded from the container.

CLI:

  • Updated TailwindCSS to v3.

0.16.0

23 May 11:53
Compare
Choose a tag to compare

This release marks a major milestone in WP Emerge's evolution. A significant portion of the framework, app core and starter theme have been reworked and refactored to improve performance, extensibility, stability and multi-instance use.
While there are a number of breaking changes in this release, no further major changes are expected before 1.0 is shipped!

Getting started:

Quick Summary:

  • An official WP Emerge Starter Plugin is now available!
  • [Framework] Facades have been replaced with a new App class which has static aliases for each facade.
  • [Framework] The new App class allows several instances to live side by side allowing multiple plugins to use WP Emerge at the same time.
  • [Framework] WPEmerge\*() functions are now App::*() aliases which are swappable during testing.
  • [Framework] Added named routes.
  • [Framework] Improved configuration and extensibility.
  • [Framework] Simplified internals.
  • [Framework] Improved overall performance.
  • [Theme/Plugin] Added an automatically generated SVG sprite (props @paulomfr).
  • [Theme/Plugin] Added a new yarn rebrand command to automatically rename the MyApp namespace and related constant/function names.
  • [Theme/Plugin] Major improvements to the build and release pipelines.
  • [Theme/Plugin] Improved Bedrock support.

Framework Breaking Changes

  • Facades have been removed entirely. While very convenient to use, facade classes ultimately made having multiple WP Emerge instances running alongside each other impossible.
    Accessing your various services statically is now done via an App class.
    Refer to the updated documentation to learn where this new app class comes from.
    • Application is now \App.
    • Csrf is now \App::csrf().
    • Flash is now \App::flash().
    • OldInput is now \App::oldInput().
    • Response is now \App::responses().
    • Route is now \App::route().
    • View is now \App::views().
    • ViewEngine has been removed - pass it as a constructor dependency if you need it.
    • WPEmerge\response() is now \App::response().
    • WPEmerge\output() is now \App::output().
    • WPEmerge\json() is now \App::json().
    • WPEmerge\redirect() is now \App::redirect().
    • WPEmerge\view() is now \App::view().
    • WPEmerge\error() is now \App::error().
    • WPEmerge\render() is now \App::render().
    • WPEmerge\layout_content() is now \App::layoutContent().
    • WPEmerge\run() is now \App::run().
  • The new App class makes it possible to have several WP Emerge instances workign side-by-side which was critical in order to support WP Emerge usage in plugins - check out the WP Emerge Starter Plugin below.
  • The new App class makes testing significantly easier as you can mock any and all aliases during testing:
    // Since we don't want to test WP Emerge internals,
    // we can overwrite them during testing:
    \App::alias( 'view', function ( $view ) { return $view; } );
    
    // or we can replace the entire app instance:
    \App::setApplication( new MyMockApplication() );
  • The Blade and Twig extensions now use the new WP Emerge generic cache directory configuration option by default - see "What's New" for more information.
  • \WPEmerge\Requests\RequestInterface now extends Psr\Http\Message\ServerRequestInterface.
  • \WPEmerge\Requests\Request is now PSR-7 compatible with Psr\Http\Message\ServerRequestInterface.
    Several methods have been affected:
    • Request::get() is now Request::query().
    • Request::post() is now Request::body().
    • Request::cookie() is now Request::cookies().
    • Request::headers( $key, $default ) will now return an array of header values if $key is specified or an associative array of arrays of values otherwise.
      If you wish to get the value for a header as a single string use Request::getHeaderLine( $key ) instead.
  • \WPEmerge\Routing\RouteInterface::handle() has been replaced with a new getHandler() method. \WPEmerge\Routing\Route class has been updated to match.
  • 'routes' configuration value structure has been altered slightly to allow you to override the default attributes.
    // Before:
    'routes' => [
        'web' => 'web.php',
        'admin' => 'admin.php',
        'ajax' => 'ajax.php',
    ],
    
    // After:
    'routes' => [
        'web' => [
          'definitions' => 'web.php',
          // Optional:
          'attributes' => [ ... ],
        ],
        'admin' => [
          'definitions' => 'admin.php',
          // Optional:
          'attributes' => [ ... ],
        ],
        'ajax' => [
          'definitions' => 'ajax.php',
          // Optional:
          'attributes' => [ ... ],
        ],
    ],
  • The App Layout comment annotation for PHP views has been changed to just Layout.
  • Removed Response::view() - use \App::view() instead.
  • Application::getContainer() is now \App::container().
  • NameProxyViewEngine::__construct() signature has changed.
  • ErrorHandle::__construct() signature has changed.
  • Various other internal classes have had their constructor signatures changed.
  • The 'whoops' key in the container has been changed to 'Whoops\Run' (\Whoops\Run::class).

What's New

Framework

  • Added named routes.
    You can now assign unique names to your routes and then refer to them to generate a route url:
    // Adding a name to a route:
    \App::route()
        ->get()
        ->url( '/dashboard/{user}' )
        ->name( 'user-dashboard' )
        ->handle( ... );
    
    // Getting a route URL even with arguments:
    App::routeUrl( 'user-dashboard', [ 'user' => 123 ] );
  • There is now a new 'cache' configuration key which allows you to override the default directory which extensions should use for caching purposes.
    The default value is {Uploads Directory}/wpemerge/cache.
  • You can now get the current route instance from inside middleware or controllers using $request->getAttribute( 'route' ).
  • You can now get the current route arguments from inside middleware or controllers using $request->getAttribute( 'route_arguments' ).
  • You can now specify middleware at the controller level, with options to specify which methods that middleware should apply to:
    use WPEmerge\Middleware\HasControllerMiddlewareInterface;
    use WPEmerge\Middleware\HasControllerMiddlewareTrait;
    
    class MyController implements HasControllerMiddlewareInterface {
        use HasControllerMiddlewareTrait;
    
        public function __construct() {
          $this->middleware( 'middleware1' );
          $this->middleware( 'middleware2' )->only( 'method1' );
          $this->middleware( 'middleware3' )->except( 'method2' );
        }
    }
  • A new \Whoops\Handler\PrettyPageHandler::class key is available in the container which provides access to the Whoops error screen instance. Useful if you wish to blacklist environment values from appearing e.g.:
    $container[ \Whoops\Handler\PrettyPageHandler::class ]->blacklist( '_ENV', 'MYSQL_PASSWORD' );
  • View composers are now applied to top-most templates loaded by WordPress even when a route is not active.
  • PHP mixin classes are now shipped with the framework which help IDEs detect built-in Application aliases.
  • You can now configure default route attributes for every group (web, admin, ajax) via configuration.
  • A WPEMERGE_VERSION constant has been added to provide easy programatical access to the currently loaded WP Emerge version.
  • Added a 'debug'->'enable' configuration option allowing you to override the debug status of WP Emerge. The value defaults to the value of WP_DEBUG.
  • Added a new 'view_composers' configuration option which gives control over view composer settings. Currently allows you to adjust the default namespace for view composer classes.
  • Action name can now be passed to the csrf middleware (e.g. 'csrf:my_nonce_action_goes_here').
  • Errors caught by the ErrorHandler class will now be logged to debug.log as well.
  • Added a new App::closure() helper which gives static access to container services. Allows taking advantage of the service container outside of WP Emerge (e.g. for REST API handling).
  • Query filters can now be applied to custom route conditions as long as they implement the new \WPEmerge\Routing\HasQueryFilterInterface interface.
  • Admin and AJAX error responses will not attempt to load error-admin.php and error-ajax.php, respectively, falling back to error.php if not available.
  • Simplified internals.
  • Improved overall performance.
  • Removed the autoloaded load.php and functions.php files.
  • Fixed duplicate headers in certain cases (htmlburger/wpemerge-theme#35).
  • Fixed extendConfig() merging indexed arrays incorrectly.
  • Fixed 'get_header', 'get_footer' and similar actions being called twice when usin...
Read more

0.15.0

03 Jun 19:28
Compare
Choose a tag to compare

The release of 0.15.0 is a major stepping stone towards a stable 1.0.0 release. As such, it includes a number of minor breaking changes aimed at extensibility and consistency across the board.

What's New

  • Defining routes and route groups has been completely rewritten (docs).

  • You can now define Web, Admin and AJAX routes each with their own global middleware.

  • Automatic namespace prefixes have been added for Controllers, View Composers and Middleware.
    This allows you to define controllers like this:

    HomeController@home

    which will be automatically prefixed like this:

    \App\Controllers\HomeController@home

    Note: you can still use fully qualified class names - the prefix is only added if the class does not exist.

  • Route namespace prefixes can be adjusted on a per-group or per-route basis.
    For example this:

    Route::setNamespace( '\\App\\Controllers\\Dashboard\\')->group( function () {
      Route::get()->url( '/dashboard/profile' )->handle( 'Profile@view' );
    } );

    will result in this:

    \App\Controllers\Dashboard\Profile@view
  • Added a new Route::view() shortcut to directly rendering a view in response to a request.
    Example:

    Route::get()->url( '/' )->view( 'index.php' );
  • Middlewares now use string aliases that you need to register in your configuration (docs).
    Example:

    // Configuration:
    'middleware' => [
      'foo' => FooMiddleware::class,
    ],
    
    // Routes:
    Route::middleware( 'foo' )->...
  • Added ability to pass basic parameters to middleware (docs).
    Example:

    Route::middleware( 'user.can:manage_options' )->...
  • Arbitrary middleware groups can now be created and assigned as middleware to routes by utilizing the new aliases functionality. You can even reference groups within groups (docs).
    Example:

    // Configuration:
    'middleware_groups' => [
      'privileged' => [
        'user.logged_in',
        'user.can:manage_options',
      ],
    ],
    
    // Routes:
    Route::middleware( 'privileged' )->...
  • Middleware ordering has been simplified and made consistent in cases where priority has not been specified (docs).

  • Middleware classes are now instantiated through the container allowing for dependency injection.

  • Introduced several new built-in middlewares to deal with authentication and authorization: user.logged_in, user.logged_out and user.can (docs).

  • Introduced WPEmerge\run() which allows you to run a full middleware + controller pipeline and get a response object independently from defined routes.
    Running this:

    $response = \WPEmerge\run( \WPEmerge\Requests\Request::fromGlobals(), ['user.logged_in'], function ( $request, $foo ) {
      return 'Hello ' . $foo;
    }, ['World'] );

    will result in a PSR-7 response object be it a redirect response if the user is not logged in due to the middleware supplied or a 200 OK response with a body of 'Hello World'.
    If you want to output the response as usual you can use \WPEmerge\Facades\Response::respond( $response );

  • Added support for multiple views directories for all view engines.
    You can now specify a single path or an array of paths.

  • Fixed a race condition in Blade and Twig which caused global variables to not be available if registered too early.

  • The URL condition now has full regular expression support through a new parameter (docs).
    Example:

    Route::get()->url( '/year/{year}', ['year' => '/^\d+$/'] )->...
  • Added @method annotations for every facade class for improved IDE support.

  • Various codebase-covering improvements targeting consistency and simplicity.

  • Various improvements to the documentation including a new CONTRIBUTING.md file in the repository.

Breaking Changes

  • Routes now must be defined in a separate file and then referenced in the configuration (docs):

    // Configuration:
    'routes' => [
      'web'   => 'routes/web.php',
      'admin' => 'routes/admin.php',
      'ajax'  => 'routes/ajax.php',
    ],

    All groups are optional so you do not need to create an admin routes file if you have no admin routes.

  • Fixed PHP layout hierarchy being executed in the incorrect order (inside-out instead of outside-in).

  • Direct \WPEmerge\Requests\Request references have been replaced with a new \WPEmerge\Requests\RequestInterface interface.

  • app_response() is now \WPEmerge\response().

  • app_output is now \WPEmerge\output().

  • app_json is now \WPEmerge\json().

  • app_redirect is now \WPEmerge\redirect().

  • app_view is now \WPEmerge\view().

  • app_error is now \WPEmerge\error().

  • app_partial is now \WPEmerge\render().

  • app_layout_content is now \WPEmerge\layout_content().

  • ->add() is now ->middleware()

  • Routes are no longer declared using Router::. See here for more information.

  • Router::handleAll() is now Route::all().

  • The ability to specify a regular expresson inline for a URL condition parameter has been removed. Use the new separate URL condition parameter instead (docs).

  • The RouteCondition facade has been removed.

  • ServiceProviderInterface::boot() is now ServiceProviderInterface::bootstrap().

  • WPEmerge::boot() is now WPEmerge::bootstrap().

  • Framework facade is now WPEmerge.

  • WPEMERGE_FRAMEWORK_KEY constant is now WPEMERGE_APPLICATION_KEY.

  • WPEmerge::facade() is now WPEmerge::alias().

  • MiddlewareInterface has been removed and is no longer required for middleware.

  • Blade and Twig extensions will now proxy .php view rendering to the default view engine by default.

  • An exception will no longer be thrown if manifest.json is missing.

0.11.1

01 Dec 00:51
Compare
Choose a tag to compare
  • Fixed ExtendsConfigTrait causing defaults to override user-defined values.
  • Various minor project infrastructure improvements.

0.11.0

27 Oct 20:02
Compare
Choose a tag to compare

Breaking Changes

  • Removed Route::rewrite() and replaced it with Route::query() (docs).

Other Changes

  • Added @see annotations to all facades for easy IDE navigation to the classes they resolve to.
  • Housecleaning (improved test coverage, code style fixes, implemented PHPCS etc.).

0.10.1

12 Sep 19:25
Compare
Choose a tag to compare
  • [HOTFIX] Fixed overly aggressive security check preventing CLI interactions.

0.10.0

11 Sep 09:51
Compare
Choose a tag to compare

Note: until we hit 1.0.0, minor versions will be considered major (i.e. may include breaking changes).
Note: almost all of these changes are breaking changes so make sure you adjust your usage accordingly when updating.

  • A new documentation website with improved docs, search and features is up: https://docs.wpemerge.com/#/framework/overview
  • Prevented direct access to files with imperative code.
  • app_partial() is now app_render()
  • app_render() will now call the default get_[header|sidebar|footer] hook when using it for the header, sidebar or footer core partials.
  • Config option global_middleware_default_priority is now called middleware_default_priority. Make sure to update your config if you are using it.
  • Config option global_middleware_priority is now called middleware_priority. Make sure to update your config if you are using it.
  • Restructured built-in exception classes (see changes in 2736caf)
    • WPEmerge\Exceptions\NotFoundException is now WPEmerge\Routing\NotFoundException
    • WPEmerge\Exceptions\InvalidCsrfTokenException is now WPEmerge\Csrf\InvalidCsrfTokenException
    • WPEmerge\Exceptions\ViewException is now WPEmerge\View\ViewException
    • Added a new WPEmerge\View\ViewNotFoundException which is thrown from view engines when they fail to find a view.

0.9.3

24 Aug 21:42
Compare
Choose a tag to compare

0.9.2

28 Jul 10:19
Compare
Choose a tag to compare
  • Hotfix: Fatal error: Uncaught Error: Class 'Whoops\Run' not found

0.9.1

27 Jul 22:31
Compare
Choose a tag to compare
  • Added Advanced Error Reporting and improved error handling capabilities.
  • Allowed request method overriding using the _method POST parameter.
  • Route arguments can now be accessed in middleware more easily:
    Router::getCurrentRoute()->getArguments()
    
  • Various documentation improvements (props @galengidman).