Download the PHP package aurmil/slim3-skeleton-wordpress without Composer

On this page you can find all versions of the php package aurmil/slim3-skeleton-wordpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package slim3-skeleton-wordpress

Slim 3 Skeleton with WordPress support

WordPress handles content management while Slim is used for front-office rendering, mixing content from WordPress and custom pages/templates.

But... why?! :hushed: I needed a very specific multilingual/multicountry routing system (not included here, too specific to the project) for a website having a user-friendly back office for managing content. And also... for fun :smiley:

What's included?

Installation and usage

I invite you to read first the short documentation I wrote for my app skeleton.

Required: PHP 7 and Composer

Run the following command, replacing [your-project-name] with the name of the folder you want to create.

.htaccess file, Web server choice, virtual host, AllowOverride All, var folder permissions... please refer to the main documentation.

WordPress:

WordPress integration

Meta title

The config entry app.title from the Slim 3 app skeleton is not used here. Instead of it, title is read from WordPress configuration.

On the home page, meta title is composed of blog name + blog description, as in a normal WordPress home page.

Posts lists

WordPress handles on its onw the number of posts to display in lists.

All pages displaying a list of posts (home, category, tag, ...) include an optional parameter at the end of their route: /page/{page} for pagination.

Routes

I read all routes formats from WordPress to minimize errors, avoid future compatibility problems and support changes in WordPress configuration (eg: edit category or tag base in admin area).

WordPress contents routing in Slim app tries to stick as much as possible to the original WordPress routes. I also consider the optional use of a trailing slash in WordPress contents routes. It depends if permalink structure ends or not with a slash in WordPress permalinks settings.

You can add your own routes for classic Slim pages/contents but take care that they do not match a WordPress-content route.

Cache

If config entry app.use_cache is set to true, WordPress routes are stored in cache with a duration that can be confgured in wordpress.yaml configuration file (default: 1 day).

This app cache can be flushed through the route /clear-cache which is protected with a basic HTTP auth. Allowed users are defined in security.yaml configuration file.

Posts

I let WordPress build posts permalinks with get_permalink() then I use them to build posts routes in Slim app.

I decided to create one route per post because it allows you to use pathFor('wp-post-{post_id}') (router->pathFor() in Slim app code and path_for() in Twig templates) without having to know the post permalink structure. If you change permalink structure in WordPress admin area, you won't have to change your code, posts links will remain valid.

Pages

Route: /{page_slug}, read from $wp_rewrite->get_page_permastruct()

As it is directly on app root (/), we can't match everything ([a-zA-Z0-9_-]+) as it would prevent to use other root routes. So, the existing pages slugs are dynamically listed in this route to only match relevant URI.

Categories

Route: /{category_base}/{category_slug}, read from $wp_rewrite->get_category_permastruct()

Tags

Route: /{tag_base}/{tag_slug}, read from $wp_rewrite->get_tag_permastruct()

Authors

Route: /author/{author_slug}, read from $wp_rewrite->get_author_permastruct()

Archives

WordPress supports many types of archives list: yearly, monthly, daily, weekly and a simple list of posts. Each type has a route pattern I tried to reuse (except the last one which belongs to classic posts routes):

Where yyyy = 1900 - 2099, mm = 01 - 12, dd = 01-31, w = 1 - 53.

Search

By default, WordPress uses GET parameters on main page, eg: /?s=test. I did the same but with a dedicated route: /search, read from $wp_rewrite->get_search_permastruct().

For a prettier URI format when search results are paginated, I also support /search/{search}, to avoid this: /search/page/5/?s={search}.

Specific classes

App\Controllers\WordPressController: contains all WordPress-related actions. Basically, every action reads received parameters, ask WordPress to fetch corresponding items, pass them to the model to be processed and then pass the result(s) to the view, along with pagination data when necessary.

App\Models\WordPress\PostConverter: transforms WP_Post object(s) into standard PHP object(s), using WordPress functions, for easier further use / access to posts data.

App\TwigExtensions\WordPress: declares Twig functions allowing to access WordPress functions in templates files (post thumbnail, post meta, nav menu, ...). Functions names and parameters are mostly the same as in WordPress:

This class also includes a custom function replaceWordpressLinks($html), available through Twig function replace_wp_links(html). When fetching data from WordPress, if there are some links, they all point to the WordPress pages as expected. But we need them to point on Slim pages. This function does this job, replacing links href values.

This can only work if WordPress and Slim app routing patterns are the same, which is the way I made this skeleton. If you changed the WordPress contents routes in Slim app, you would have to handle this.

Layout

In templates/layouts/main.twig, set the name of the menu you want to display in wp_nav_menu call.

Layout also contains a search form next to the nav menu. You will have to uncomment this form after successfully installing WordPress in app public dir.

To do

License

The MIT License (MIT). Please see License File for more information.


All versions of slim3-skeleton-wordpress with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
akrabat/rka-slim-session-middleware Version ^2.0
illuminate/cache Version ^5.5
illuminate/filesystem Version ^5.5
monolog/monolog Version ^1.21
roave/security-advisories Version dev-master
slim/csrf Version ^0.8.1
slim/flash Version ^0.2.0
slim/slim Version ^3.5
slim/twig-view Version ^2.2
swiftmailer/swiftmailer Version ^6.0
symfony/yaml Version ^3.1
tuupola/slim-basic-auth Version ^2.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aurmil/slim3-skeleton-wordpress contains the following files

Loading the files please wait ....