Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

[WIP] Add additional structure and comments to create more of a skeleton #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;

/**
* Short Description of module
*
* Long Description of module
*/
class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
Expand All @@ -33,12 +38,22 @@ public function getConfig()
return include __DIR__ . '/config/module.config.php';
}

public function onBootstrap($e)
public function onBootstrap($event)
{
// You may not need to do this if you're doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$eventManager = $event->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}

/*
public function init($moduleManager)
{
// Any module dependencies your module relies on could be placed here
// load will throw an exception if the module can't be loaded
// $moduleManager->load('someModule');

}
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't add this. onBootstrap is more likely to be utilized at this point, and we don't want to encourage using init() as it will get triggered for every page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney, Well, for the specific feature that he has commented out here, init() would be the proper place to do it (bootstrap is too late for this to work properly). That said, we really just need to document it in the docs, where we can appropriately add more warnings about the potential performance pitfalls of doing stuff in init().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self, this should be changed to $mm->loadModule

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also look at your indentation @ line 54

}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Sample, skeleton module for use with the ZF2 MVC layer.
Sample skeleton module for use with the ZF2 MVC layer.
8 changes: 8 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<?php
return array(
// as the configuration is one large array, place your module specific
// config inside a key unique to your module.
'zend_skeleton_module' => array(

),
// controller config
'controllers' => array(
'invokables' => array(
'skeleton' => 'ZendSkeletonModule\Controller\SkeletonController',
),
),
// define any routes the module needs
'router' => array(
'routes' => array(
'module-name-here' => array(
Expand Down Expand Up @@ -42,6 +49,7 @@
),
),
),
// define options for the view manager
'view_manager' => array(
'template_path_stack' => array(
'ZendSkeletonModule' => __DIR__ . '/../view',
Expand Down
22 changes: 22 additions & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Data Directory
=================

Sql files for your module can be placed here with a filename: "name.dbtype.sql"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than just sql files -- you might want to put default keys, sqlite databases, and more in this directory -- it's data the module may need to consume, but not necessarily restricted to databases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to add when using sqlite, directory needs to be writable so journal files can be created by sqlite else a cryptic message is created.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that we should not necessarily promote putting anything in here that would be written to at runtime.


name: The name can be anything. It's suggested you use the name 'schema' for sql files
which create compulsory sql, and any other name for optional sql code.

dbtype: This denotes what engine the sql code is for:
sqlite
mysql
postgresql
sqlserver
sql92

Examples
---------

* schema.mysql.sql compulsory sql code that the modules needs to run

* featurefoo.sqlite.sql optional sql code for sqlite which the module can use to add extra feature/s
6 changes: 6 additions & 0 deletions public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Public
========

This directory is for the benefit of the users of your module. Place files you need for public web access
inside here with the structure you need. Users can either symlink / copy files as necessary.
5 changes: 5 additions & 0 deletions public/css/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

CSS Files
==========

Place CSS files here
5 changes: 5 additions & 0 deletions public/js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

js
====

Place javascript files in here