Skip to content

Commit

Permalink
Fixed installation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Jun 18, 2015
1 parent 1fa3742 commit 5b3abce
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 84 deletions.
156 changes: 78 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Slytherin is a simple and extensible PHP library that follows an MVC software ar

2. Add the ```Slytherin``` package in your ```require``` list in ```composer.json```:

```json
{
"require": {
"rougin/slytherin": "*"
},
"autoload": {
"psr-4": {
"Controllers\\": "app/controllers",
"Libraries\\": "app/libraries",
"Models\\": "app/models"
}
}
}
```

Then run ```$ composer install```
```json
{
"require": {
"rougin/slytherin": "*"
},
"autoload": {
"psr-4": {
"Controllers\\": "app/controllers",
"Libraries\\": "app/libraries",
"Models\\": "app/models"
}
}
}
```

Then run ```$ composer install```

3. Aaaand you're done! Try to experiment this library with other libraries that currently exists on [Packagist](https://packagist.org/) (or even here at [awesome-php](https://github.com/ziadoz/awesome-php)) and create an awesome and cool PHP project! You can also share your set of libraries in the [Wiki section](https://github.com/rougin/slytherin/wiki)! :smile:

Expand Down Expand Up @@ -53,14 +53,14 @@ use Models\Account;
*/
class Accounts extends Controller {

public function index()
{
$account = new Account();
$data['accounts'] = $account->getAll();
public function index()
{
$account = new Account();
$data['accounts'] = $account->getAll();

return View::render('accounts/index', $data);
}
return View::render('accounts/index', $data);
}
}
```

Expand All @@ -78,13 +78,13 @@ class Accounts extends Controller {
// Include your database credentials below

return array(
'default' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
)
'default' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
)
);
```

Expand All @@ -102,20 +102,20 @@ use Rougin\Slytherin\Model;
*/
class Account extends Model {

public static function getAll()
{
$accounts = array();
public static function getAll()
{
$accounts = array();

$statement = $this->databaseHandle->prepare('SELECT * FROM account');
$statement->execute();
$statement->setFetchMode(\PDO::FETCH_OBJ);
$statement = $this->databaseHandle->prepare('SELECT * FROM account');
$statement->execute();
$statement->setFetchMode(\PDO::FETCH_OBJ);

while ($row = $statement->fetch()) {
$accounts[] = $row;
}
while ($row = $statement->fetch()) {
$accounts[] = $row;
}

return $accounts;
}
return $accounts;
}

}
```
Expand All @@ -128,20 +128,20 @@ You can also specify the database connection to be used in a model. For example,

```php
return array(
'default' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
),
'my_another_connection' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
)
'default' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
),
'my_another_connection' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => '',
'driver' => 'mysql'
)
);
```

Expand All @@ -158,20 +158,20 @@ $data['accounts'] = $account->getAll();

```php
<table>
<thead>
<tr>
<th>Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<?php foreach ($accounts as $account): ?>
<tr>
<td><?php echo $account->name; ?></td>
<td><?php echo $account->username; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<thead>
<tr>
<th>Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<?php foreach ($accounts as $account): ?>
<tr>
<td><?php echo $account->name; ?></td>
<td><?php echo $account->username; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
```

Expand All @@ -188,10 +188,10 @@ namespace Libraries;
* @category Libraries
*/
class SampleLibrary {
public static function sayHello($name) {
return 'Hello ' . $name . '!';
}
public static function sayHello($name) {
return 'Hello ' . $name . '!';
}

}
```
Expand All @@ -211,12 +211,12 @@ use Libraries\SampleLibrary;

class Welcome extends Controller {

public function index()
{
$name = 'Slytherin';
public function index()
{
$name = 'Slytherin';

return SampleLibrary::sayHello($name);
}
return SampleLibrary::sayHello($name);
}

}
```
Expand Down
15 changes: 9 additions & 6 deletions src/Installer/Installer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php namespace Rougin\Slytherin\Installer;

use Composer\Installer\PackageEvent;
use Composer\Script\Event;

/**
* Installer Class
*
Expand All @@ -13,7 +16,7 @@ class Installer
*
* @return integer
*/
public static function slytherize(Event $event)
public static function slytherize(Event $event = null)
{
/**
* Creates a series of directories
Expand Down Expand Up @@ -48,7 +51,7 @@ public static function slytherize(Event $event)
*/

if ( ! file_exists('app/controllers/Welcome.php')) {
$welcome = file_get_contents('Welcome.txt');
$welcome = file_get_contents(__DIR__ . '/Welcome.txt');

$file = fopen('app/controllers/Welcome.php', 'wb');
file_put_contents('app/controllers/Welcome.php', $welcome);
Expand Down Expand Up @@ -77,7 +80,7 @@ public static function slytherize(Event $event)
* Creates a .htacess for clean urls
*/

$htaccess = file_get_contents('Htaccess.txt');
$htaccess = file_get_contents(__DIR__ . '/Htaccess.txt');

$file = fopen('.htaccess', 'wb');
chmod('.htaccess', 0777);
Expand All @@ -89,7 +92,7 @@ public static function slytherize(Event $event)
*/

if ( ! file_exists('index.php')) {
$index = file_get_contents('Index.txt');
$index = file_get_contents(__DIR__ . '/Index.txt');

$file = fopen('index.php', 'wb');
chmod('index.php', 0777);
Expand All @@ -102,7 +105,7 @@ public static function slytherize(Event $event)
*/

if ( ! file_exists('app/config/databases.php')) {
$database = file_get_contents('Databases.txt');
$database = file_get_contents(__DIR__ . '/Databases.txt');

$file = fopen('app/config/databases.php', 'wb');
file_put_contents('app/config/databases.php', $database);
Expand All @@ -114,7 +117,7 @@ public static function slytherize(Event $event)
*/

if ( ! file_exists('app/config/routes.php')) {
$routes = file_get_contents('Routes.txt');
$routes = file_get_contents(__DIR__ . '/Routes.txt');

$file = fopen('app/config/routes.php', 'wb');
file_put_contents('app/config/routes.php', $routes);
Expand Down

0 comments on commit 5b3abce

Please sign in to comment.