Showing posts with label Komputer. Show all posts
Showing posts with label Komputer. Show all posts
Friday, May 22, 2015 3 comments

Membuat Extension Magento

Extension magento mengikuti skema penamaan umum, Namespace_Module. Hal ini sangat penting untuk diingat dan kita perlu berhati-hati tentang bagaimana kita memberi nama kelas. Setiap extension magento akan dibuat di direktori:

/app/code/local

Tanpa perlu basa-basi, langsung aja ikuti step demi step dalam pembuatan extension magento berikut:

struktur dari extension yang akan kita buat:

/app/code/local/<Namespace>/<Module>/

Block/
controllers/
etc/
Model/
    Mysql4/
        <Module>/
sql/
    <module>_setup/
/app/design/frontend/<interface>/<theme>/

template/
    <module>/

Activate Module

/app/etc/modules/<Namespace>_<Module>.xml

<?xml version="1.0"?>
<config>
    <modules>
        <[Namespace]_[Module]>
            <active>true</active>
            <codePool>local</codePool>
        </[Namespace]_[Module]>
    </modules>
</config>

Create Controller


/app/code/local/<Namespace>/<Module>/controllers/IndexController.php

<?php
class <Namespace>_<Module>_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
            $this->loadLayout();
            $this->renderLayout();
    }
}

Create Configuration XML


/app/code/local/<Namespace>/<Module>/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <[Namespace]_[Module]>
            <version>0.1.0</version>
        </[Namespace]_[Module]>
    </modules>
    <frontend>
        <routers>
            <[module]>
                <use>standard</use>
                <args>
                    <module>[Namespace]_[Module]</module>
                    <frontName>[module]</frontName>
                </args>
            </[module]>
        </routers>
        <layout>
            <updates>
                <[module]>
                    <file>[module].xml</file>
                </[module]>
            </updates>
        </layout>
    </frontend>
    <global>
        <models>
            <[module]>
                <class>[Namespace]_[Module]_Model</class>
                <resourceModel>[module]_mysql4</resourceModel>
            </[module]>
            <[module]_mysql4>
                <class>[Namespace]_[Module]_Model_Mysql4</class>
                <entities>
                    <[module]>
                        <table>[module]</table>
                    </[module]>
                </entities>
            </[module]_mysql4>
        </models>
        <resources>
            <[module]_setup>
                <setup>
                    <module>[Namespace]_[Module]</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </[module]_setup>
            <[module]_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </[module]_write>
            <[module]_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </[module]_read>
        </resources>
        <blocks>
            <[module]>
                <class>[Namespace]_[Module]_Block</class>
            </[module]>
        </blocks>
        <helpers>
            <[module]>
                <class>[Namespace]_[Module]_Helper</class>
            </[module]>
        </helpers>
    </global>
</config>

Create Helper


/app/code/local/<Namespace>/<Module>/Helper/Data.php

<?php

class <Namespace>_<Module>_Helper_Data extends Mage_Core_Helper_Abstract
{

}

Create Models


/app/code/local/<Namespace>/<Module>/Model/<Module>.php

<?php

class <Namespace>_<Module>_Model_<Module> extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('<module>/<module>');
    }
}


/app/code/local/<Namespace>/<Module>/Model/Mysql4/<Module>.php

<?php

class <Namespace>_<Module>_Model_Mysql4_<Module> extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {
        $this->_init('<module>/<module>', '<module>_id');
    }
}


/app/code/local/<Namespace>/<Module>/Model/Mysql4/<Module>/Collection.php

<?php

class <Namespace>_<Module>_Model_Mysql4_<Module>_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct()
    {
        //parent::__construct();
        $this->_init('<module>/<module>');
    }
}

SQL Setup

/app/code/local/<Namespace>/<Module>/sql/<module>_setup/mysql4-install-0.1.0.php

<?php

$installer = $this;

$installer->startSetup();

$installer->run("

-- DROP TABLE IF EXISTS {$this->getTable('<module>')};
CREATE TABLE {$this->getTable('<module>')} (
  `<module>_id` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `content` text NOT NULL default '',
  `status` smallint(6) NOT NULL default '0',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`<module>_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    ");

$installer->endSetup();

Template Design


/app/design/frontend/<interface>/<theme>/layout/<module>.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <[module]_index_index>
        <reference name="content">
            <block type="[module]/[module]" name="[module]" />
        </reference>
    </[module]_index_index>
</layout>


/app/design/frontend/<interface>/<theme>/layout/<module>.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <[module]_index_index>
        <reference name="content">
            <block type="core/template" name="[module]" template="[module]/[module].phtml" />
        </reference>
    </[module]_index_index>
</layout>


/app/design/frontend/<interface>/<theme>/template/<module>/<module>.phtml

<h4><?php echo $this->__('Module List') ?></h4>

<?php
        /*
        This will load one record from your database table.
        load(<module>_id) will load whatever ID number you give it.
        */
    /*
    $news = Mage::getModel('<module>/<module>')->load(1);
    echo $news->get<Module>Id();
    echo $news->getTitle();
    echo $news->getContent();
    echo $news->getStatus();
    */

        /*
        This block of code loads all of the records in the database table.
        It will iterate through the collection and the first thing it will do
        is set the Title to the current value of $i which is incremented each
        iteration and then echo that value back out.  At the very end it will
        save the entire collection.
        */
    /*
    $i = 0;
       
    $collection = Mage::getModel('<module>/<module>')->getCollection();
    $collection->setPageSize(5);
    $collection->setCurPage(2);
    $size = $collection->getSize();
    $cnt = count($collection);
    foreach ($collection as $item) {
        $i = $i+1;
        $item->setTitle($i);
        echo $item->getTitle();
    }

    $collection->walk('save');
    */

        /*
        This shows how to load one value, change something and save it.
        */

    /*
    $object = Mage::getModel('<module>/<module>')->load(1);
    $object->setTitle('This is a changed title');
    $object->save();
    */
?>

Directory Additions

Untuk kebutuhan di halaman backend:

/app/code/local/<Namespace>/<Module>/

Block/
    Adminhtml/
        <Module>/
            Edit/
                Tab/
controllers/
    Adminhtml/
etc/
Helper/
Model/
    Mysql4/
        <Module>/
sql/
    <module>_setup/
Blocks

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module> extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_controller = 'adminhtml_<module>';
        $this->_blockGroup = '<module>';
        $this->_headerText = Mage::helper('<module>')->__('Item Manager');
        $this->_addButtonLabel = Mage::helper('<module>')->__('Add Item');
        parent::__construct();
    }
}


/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
    {
        parent::__construct();
             
        $this->_objectId = 'id';
        $this->_blockGroup = '<module>';
        $this->_controller = 'adminhtml_<module>';

        $this->_updateButton('save', 'label', Mage::helper('<module>')->__('Save Item'));
        $this->_updateButton('delete', 'label', Mage::helper('<module>')->__('Delete Item'));
    }

    public function getHeaderText()
    {
        if( Mage::registry('<module>_data') && Mage::registry('<module>_data')->getId() ) {
            return Mage::helper('<module>')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('<module>_data')->getTitle()));
        } else {
            return Mage::helper('<module>')->__('Add Item');
        }
    }
}


/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Grid.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('<module>Grid');
        // This is the primary key of the database
        $this->setDefaultSort('<module>_id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
    }

    protected function _prepareCollection()
    {
        $collection = Mage::getModel('<module>/<module>')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        $this->addColumn('<module>_id', array(
            'header'    => Mage::helper('<module>')->__('ID'),
            'align'     =>'right',
            'width'     => '50px',
            'index'     => '<module>_id',
        ));

        $this->addColumn('title', array(
            'header'    => Mage::helper('<module>')->__('Title'),
            'align'     =>'left',
            'index'     => 'title',
        ));

        /*
        $this->addColumn('content', array(
            'header'    => Mage::helper('<module>')->__('Item Content'),
            'width'     => '150px',
            'index'     => 'content',
        ));
        */

        $this->addColumn('created_time', array(
            'header'    => Mage::helper('<module>')->__('Creation Time'),
            'align'     => 'left',
            'width'     => '120px',
            'type'      => 'date',
            'default'   => '--',
            'index'     => 'created_time',
        ));

        $this->addColumn('update_time', array(
            'header'    => Mage::helper('<module>')->__('Update Time'),
            'align'     => 'left',
            'width'     => '120px',
            'type'      => 'date',
            'default'   => '--',
            'index'     => 'update_time',
        ));


        $this->addColumn('status', array(

            'header'    => Mage::helper('<module>')->__('Status'),
            'align'     => 'left',
            'width'     => '80px',
            'index'     => 'status',
            'type'      => 'options',
            'options'   => array(
                1 => 'Active',
                0 => 'Inactive',
            ),
        ));

        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

    public function getGridUrl()
    {
      return $this->getUrl('*/*/grid', array('_current'=>true));
    }


}


/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Form.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $form = new Varien_Data_Form(array(
                                        'id' => 'edit_form',
                                        'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                                        'method' => 'post',
                                     )
        );

        $form->setUseContainer(true);
        $this->setForm($form);
        return parent::_prepareForm();
    }
}


/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tabs.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{

    public function __construct()
    {
        parent::__construct();
        $this->setId('<module>_tabs');
        $this->setDestElementId('edit_form');
        $this->setTitle(Mage::helper('<module>')->__('News Information'));
    }

    protected function _beforeToHtml()
    {
        $this->addTab('form_section', array(
            'label'     => Mage::helper('<module>')->__('Item Information'),
            'title'     => Mage::helper('<module>')->__('Item Information'),
            'content'   => $this->getLayout()->createBlock('<module>/adminhtml_<module>_edit_tab_form')->toHtml(),
        ));
     
        return parent::_beforeToHtml();
    }
}


/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tab/Form.php

<?php

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('<module>_form', array('legend'=>Mage::helper('<module>')->__('Item information')));
     
        $fieldset->addField('title', 'text', array(
            'label'     => Mage::helper('<module>')->__('Title'),
            'class'     => 'required-entry',
            'required'  => true,
            'name'      => 'title',
        ));

        $fieldset->addField('status', 'select', array(
            'label'     => Mage::helper('<module>')->__('Status'),
            'name'      => 'status',
            'values'    => array(
                array(
                    'value'     => 1,
                    'label'     => Mage::helper('<module>')->__('Active'),
                ),

                array(
                    'value'     => 0,
                    'label'     => Mage::helper('<module>')->__('Inactive'),
                ),
            ),
        ));
     
        $fieldset->addField('content', 'editor', array(
            'name'      => 'content',
            'label'     => Mage::helper('<module>')->__('Content'),
            'title'     => Mage::helper('<module>')->__('Content'),
            'style'     => 'width:98%; height:400px;',
            'wysiwyg'   => false,
            'required'  => true,
        ));
     
        if ( Mage::getSingleton('adminhtml/session')->get<Module>Data() )
        {
            $form->setValues(Mage::getSingleton('adminhtml/session')->get<Module>Data());
            Mage::getSingleton('adminhtml/session')->set<Module>Data(null);
        } elseif ( Mage::registry('<module>_data') ) {
            $form->setValues(Mage::registry('<module>_data')->getData());
        }
        return parent::_prepareForm();
    }
}

Controller


/app/code/local/<Namespace>/<Module>/controllers/Adminhtml/<Module>Controller.php

<?php
  
class <Namespace>_<Module>_Adminhtml_<Module>Controller extends Mage_Adminhtml_Controller_Action
{
  
    protected function _initAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('<module>/items')
            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
        return $this;
    }   
    
    public function indexAction() {
        $this->_initAction();       
        $this->_addContent($this->getLayout()->createBlock('<module>/adminhtml_<module>'));
        $this->renderLayout();
    }
  
    public function editAction()
    {
        $<module>Id     = $this->getRequest()->getParam('id');
        $<module>Model  = Mage::getModel('<module>/<module>')->load($<module>Id);
  
        if ($<module>Model->getId() || $<module>Id == 0) {
  
            Mage::register('<module>_data', $<module>Model);
  
            $this->loadLayout();
            $this->_setActiveMenu('<module>/items');
            
            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
            
            $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
            
            $this->_addContent($this->getLayout()->createBlock('<module>/adminhtml_<module>_edit'))
                 ->_addLeft($this->getLayout()->createBlock('<module>/adminhtml_<module>_edit_tabs'));
                
            $this->renderLayout();
        } else {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('<module>')->__('Item does not exist'));
            $this->_redirect('*/*/');
        }
    }
    
    public function newAction()
    {
        $this->_forward('edit');
    }
    
    public function saveAction()
    {
        if ( $this->getRequest()->getPost() ) {
            try {
                $postData = $this->getRequest()->getPost();
                $<module>Model = Mage::getModel('<module>/<module>');
                
                $<module>Model->setId($this->getRequest()->getParam('id'))
                    ->setTitle($postData['title'])
                    ->setContent($postData['content'])
                    ->setStatus($postData['status'])
                    ->save();
                
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
                Mage::getSingleton('adminhtml/session')->set<Module>Data(false);
  
                $this->_redirect('*/*/');
                return;
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                Mage::getSingleton('adminhtml/session')->set<Module>Data($this->getRequest()->getPost());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                return;
            }
        }
        $this->_redirect('*/*/');
    }
    
    public function deleteAction()
    {
        if( $this->getRequest()->getParam('id') > 0 ) {
            try {
                $<module>Model = Mage::getModel('<module>/<module>');
                
                $<module>Model->setId($this->getRequest()->getParam('id'))
                    ->delete();
                    
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
                $this->_redirect('*/*/');
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            }
        }
        $this->_redirect('*/*/');
    }
    /**
     * Product grid for AJAX request.
     * Sort and filter result for example.
     */
    public function gridAction()
    {
        $this->loadLayout();
        $this->getResponse()->setBody(
               $this->getLayout()->createBlock('<module>/adminhtml_<module>_grid')->toHtml()
        );
    }
}

XML Configuration Changes

/app/code/local/<Namespace>/<Module>/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <[Namespace]_[Module]>
            <version>0.1.0</version>
        </[Namespace]_[Module]>
    </modules>
    <frontend>
        <routers>
            <[module]>
                <use>standard</use>
                <args>
                    <module>[Namespace]_[Module]</module>
                    <frontName>[module]</frontName>
                </args>
            </[module]>
        </routers>
        <layout>
            <updates>
                <[module]>
                    <file>[module].xml</file>
                </[module]>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <[module]>
                <use>admin</use>
                <args>
                    <module>[Namespace]_[Module]</module>
                    <frontName>[module]</frontName>
                </args>
            </[module]>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <[module] module="[module]">
                <title>[Module]</title>
                <sort_order>71</sort_order>            
                <children>
                    <items module="[module]">
                        <title>Manage Items</title>
                        <sort_order>0</sort_order>
                        <action>[module]/adminhtml_[module]</action>
                    </items>
                </children>
            </[module]>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <[module]>
                            <title>[Module] Module</title>
                            <sort_order>200</sort_order>
                        </[module]>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <[module]>
                    <file>[module].xml</file>
                </[module]>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <models>
            <[module]>
                <class>[Namespace]_[Module]_Model</class>
                <resourceModel>[module]_mysql4</resourceModel>
            </[module]>
            <[module]_mysql4>
                <class>[Namespace]_[Module]_Model_Mysql4</class>
                <entities>
                    <[module]>
                        <table>[module]</table>
                    </[module]>
                </entities>
            </[module]_mysql4>
        </models>
        <resources>
            <[module]_setup>
                <setup>
                    <module>[Namespace]_[Module]</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </[module]_setup>
            <[module]_write>
                <connection>
                    <use>core_write</use>
                </connection>


            </[module]_write>
            <[module]_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </[module]_read>
        </resources>
        <blocks>
            <[module]>
                <class>[Namespace]_[Module]_Block</class>
            </[module]>
        </blocks>
        <helpers>
            <[module]>
                <class>[Namespace]_[Module]_Helper</class>
            </[module]>
        </helpers>
    </global>
</config>

XML Layout

/app/design/adminhtml/<interface>/<theme>/layout/<module>.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <[module]_adminhtml_[module]_index>
        <reference name="content">
            <block type="[module]/adminhtml_[module]" name="[module]" />
        </reference>
    </[module]_adminhtml_[module]_index>
</layout>

Seperate Adminhtml Configuration

/app/code/local/<Namespace>/<Module>/etc/adminhtml.xml

<?xml version="1.0"?>
<config>
    <menu>
        <[module] module="[module]">
            <title>[Module]</title>
            <sort_order>71</sort_order>               
            <children>
                <items module="[module]">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>[module]/adminhtml_[module]</action>
                </items>
            </children>
        </[module]>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <[module]>
                        <title>[Module] Module</title>
                        <sort_order>200</sort_order>
                    </[module]>
                </children>
            </admin>
        </resources>   
    </acl>
    <layout>
        <updates>
            <[module]>
                <file>[module].xml</file>
            </[module]>
        </updates>
    </layout>
</config>

Standard Magento Admin URLs, no rewrite needed

/app/code/local/<Namespace>/<Module>/etc/config.xml

...
<admin>
    <routers>
        <!-- Includes our controller, so when we add the adminhtml menu item below, it is found! -->
        <adminhtml>
             <args>
                 <modules>
                     <[module] before="Mage_Adminhtml">[Namespace]_[Module]_Adminhtml</[module]>
                 </modules>
             </args>
         </adminhtml>
    </routers>
</admin>
<adminhtml>
    <menu>
        <[module] module="[module]">
            <title>[Module]</title>
            <sort_order>71</sort_order>               
            <children>
                <items module="[module]">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>adminhtml/[module]</action>
                </items>
            </children>
        </[module]>
    </menu>
...




»»  Selengkapnya...
Tuesday, November 4, 2014 0 comments

Laravel Controller Subfolder

Disini saya akan sedikit menjelaskan bagaimana membuat subfolder pada controller, ini biasanya digunakan untuk membuat sebuah halaman admin. langsung aja tanpa banyak basa-basi...

# Pertama masuk ke folder app -- controllers, dan buat sebuah folder (untuk nama terserah, misalkan: admin)

app
--controllers
----admin
------AdminController.php

jadinya seperti berikut ini:



# Kemudian pada composer.json, tambahkan folder baru pada line classmap ("app/controllers/admin")

"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/controllers/admin",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},

# Setelah itu jalankan "composer dump-autoload" pada command prompt dan kemudian "php artisan dump-autoload"

# Terakhir, pada routes.php masukan controller seperti berikut:

Route::controller('admin', 'AdminController');
»»  Selengkapnya...
Sunday, July 13, 2014 2 comments

Instalasi Laravel di Windows

Mungkin kalian pernah mendengar framework ini dan framework itu. Dan mungkin juga ada diantara kalian yang pernah mendengar framework laravel. Ya... Laravel sebuah framework baru yang muncul sekitar tahun 2012 yang dibuat oleh Taylor Otwell dengan mengusung ideologi “clean code” dan “expressiveness”. Framework ini mengaku “clean and classy”, kodenya lebih singkat, mudah dimengerti, dan ekspressif, jadi hanya dengan membaca sekilas kode yang ditulis Anda sudah bisa menduga apa maksudnya tanpa perlu membaca dokumentasi.

Tidak seperti framework PHP kebanyakan, dimana Anda bisa download satu set folder, taruh di web server, dan aplikasi siap dijalankan, Laravel sedikit berbeda dalam hal instalasi. Laravel memiliki dependensi (ketergantungan) terhadap beberapa library PHP lainnya, dimana library tersebut tidak disertakan dalam source laravel yang tersedia untuk didownload. Oleh karena itu Anda haru mendownload library yang dibutuhkan tersebut secara terpisah. Merepotkan? hmm.. tidak juga... 

Untuk dapat menjalankan Laravel maka ada beberapa persyaratan hardware maupun software sebagai berikut :
  1. Komputer / Laptop
  2. IDE (Integrated Development Environment)
  3. Webserver
  4. PHP versi >= 5.3
  5. Composer
Untuk memenuhi persyaratan tersebut anda dapat menggunakan sebuah software yang sudah membundle PHP, Apache, MySQL dll yaitu xampp versi terbaru (saat ini adalah versi 1.8.3). Adapun untuk keperluan kita menginstall Laravel 4 dan library-library lain yang kita butuhkan anda harus mengunduh dan menginstall Composer terlebih dahulu.

Setelah semuanya siap dan aplikasi yang dibutuhkan sudah terinstall semua, lakukan langkah-langkah dibawah ini untuk menginstall Laravel 4 di Windows:
  1. Buka http://laravel.com
  2. Klik pada menu “Github
  3. Anda akan diarahkan ke halaman github laravel
  4. Klik tombol “Download ZIP” disamping kanan
  5. Extract file “laravel-master.zip“ yang tadi anda unduh
  6. Rename folder “laravel-master” menjadi “laravel” (tanpa tanda kutip)
  7. Pindahkan ke direktori htdocs anda (misal C:\xampp\htdocs)
  8. Buka command prompt windows
  9. Arahkan ke direktori laravel dengan perintah “cd c:\xampp\htdocs\laravel
  10. Ketikkan perintah berikut pada command prompt “composer install
  11. Tunggu hingga proses installasi selesai
Berikut ini merupakan screenshot saat proses installasi Laravel 4 :



Jika proses installasi selesai sekarang coba anda ketikkan http://localhost/laravel/public/ pada URL web browser anda maka akan tampil halaman seperti berikut ini yang menunjukkan Laravel 4 berhasil diinstall di komputer anda:







»»  Selengkapnya...
Tuesday, April 2, 2013 0 comments

Blank Page In typo3

Mungkin anda pernah menemui kasus dimana di halaman admin typo3, beberapa page seperti extension manager, install tool->basic configuration, configuration, dan beberapa page lainnya di bagian admin blank (blank page). Dan saya pernah menemui kasus seperti ini, blank page penyebabnya base64 disable. untuk mengatasi masalah ini, coba check disable_function, exclude exec dan base64_decode, jika anda tidak mengetahui cara mengenablenya coba klik

http://bit.ly/Z7wFQa

atau, jika anda masih menemui kendala untuk konfigurasinya, coba anda tanyakan ke bagian support hosting anda.
»»  Selengkapnya...
Tuesday, November 6, 2012 0 comments

Search Engine dengan Sphinx


Pernah kepikiran untuk membuat search engine? atau pernah kepikiran ingin menyamai kesuksesan google dalam mengusai dunia search engine. Rasanya, raksasa yang satu ini agak susah untuk disamai. tapi tidak menutup kemungkinan kita bisa melebihi kesuksesan google. Bukti nyata, kompetitor dia sekarang adalah facebook, yang bisa di bilang sang anak bawang. Karena facebook terlahir setelah google sudah sukses seperti sekarang ini. Facebook sekarang menjadi momok kompetitor nyata bagi sang raksasa search engine. Karena sebagian besar pengguna internet sekarang pengakses facebook. Tapi, kalau urusan search engine... Google bisa di bilang "seng ada lawan...". Eh Kok, jadi ngurusin kesuksesan google.. hahaha.. yang mau kita bahas disini kan tentang serach engine.
Tenang-tenang.. sabar coy.. itu cuma selingan.. Ok, kali ini saya akan membahas bagaimana caranya membuat search engine sederhana. Tapi, disini kita akan menggunakan sebuah framework yang sudah cukup familiar.. yaitu.. Sphinx Serach. Mungkin disini saya tidak akan membahasa bagaimana sistem kerja dari Sphinx Search ini, yang akan saya bahas disini yaitu bagaimana membuat search engine sederhana menggunakan framework ini. Ok, langsung saja ikuti step by stepnya...

  1. Download SphinxSearch ( Download Sphinx Search ), kemudian pilih versi yang sesuai dengan OS Anda.
  2. Kemudian ekstrak file hasil download tadi sehingga menghasilkan folder “sphinx”
  3. Copy-kan folder sphinx tadi ke drive mana saja, tetapi disarankan ke drive C: agar lebih mudah mengikuti langkah-langkah di postingan ini. :d
  4. Buat file corpus (koleksi dokumen) dengan format xml, isinya bebas, atau Anda dapat meng-copy berikut ini :
  5. Yang perlu diperhatikan adalah tag penyusun untuk setiap dokumen, yaitu <sphinx:field/> yang berfungsi sebagai penunjuk bagian apa saja dari dokumen yang ingin kita index, pada contoh diatas adalah title dan content dari dokumen.

  6. Kemudian buka folder sphinx dan buat 3 folder baru dengan nama “data”, “corpus” dan “log”. Kemudian copy file corpus.xml yang telah dibuat tadi ke dalam folder corpus.
  7. Kemudian edit file sphinx.conf yang ada di dalam folder C:sphinx (bisa dibuka dengan notepad++ biar lebih mudah editnya), kemudian ganti semua isinya dengan kode di bawah ini.
  8. Langkah selanjutnya adalah mengindex corpus yang telah kita buat dengan menggunakan command prompt. Bagi pengguna Windows Vista/7/8 harus menjalankan command prompt sebagai Administrator (Run As Administrator), setelah jendela command prompt terbuka jalankan perintah ini:
    c:\sphinx\bin\indexer.exe --config c:\sphinx\sphinx.conf --all
  9. Apabila sukses langkah selanjutnya adalah dengan membuat service, masih lewat command prompt ketikan perintah ini:
    c:\sphinx\bin\searchd --install --config c:\sphinx\sphinx.conf --servicename MySphinx

    Nama service di atas dicontohkan dengan “MySphinx” tapi nama service tersebut dapat terserah Anda.
  10. Langkah terakhir adalah, copy file “sphinxapi.php” dari folder sphinx->apikedalam htdoc (contohnya saya menggunakan XAMPP) Kemudian buat file php sederhana sebagai antar muka sistem.
  11. index.php
    result.php
    style.css
»»  Selengkapnya...
Saturday, September 15, 2012 3 comments

Membuat Kabel jaringan dengan UTP


Kabel Network terdiri atas 2 jenis yaitu Straight-through Cable (Kabel Straight) dan Crossover Cable (Kabel Cross). Tujuan dan penggunaannya sama, hanya berbeda pada orientasinya saja, Straight Cable digunakan untuk menghubungkan beberapa client dengan menggunakan bantuan hub atau switch sebagai network manager. Sedangkan Crossover Cable, dapat digunakan untuk menghubungkan 2 unit client secara langsung, ataupun menghubungkan single computer dengan router.
Alat dan bahan yang dibutuhkan :
1.        UTP Cable
Pastikan jenisnya CAT5 atau CAT6 yang merupakan standar internasional.

Gambar 1. Kabel UTP




2.        Konektor RJ-45
RJ merupakan singkatan dari (Registered Jack). Untuk kabel telepon biasanya menggunakan RJ-11, dan untuk kabel network tipenya RJ45.

Gambar 2. Konektor RJ-45
3.        Crimping Tool
Berfungsi sebagai alat menyatukan dan menjepit kabel dengan konektor RJ, selain juga bisa dipakai untuk memotong kabel.
Gambar 3. Crimping Tool


4.        Cable Tester
Berfungsi untuk mengetes apakah kabel sudah dirakit berfungsi dengan benar. Tanpa ini, kita akan sedikit repot untuk mengetesnya langsung pada instalasi jaringan.
Gambar 4. Cable Tester
5.        Gunting
Digunakan untuk memotong dan merapikan kabel agar lebih mudah dimasukkan kedalam lubang connector RJ-45.
Gambar 5. Gunting

Merancang Kabel dan mengujinya :
1.        Siapkan kabel UTP sepanjang yang kita ingin gunakan misalnya 1 meter, atau lebih dengan catatan: panjang maksimum disarankan tidak lebih dari 100 meter karena semakin jauh jaraknya, maka tingkat LOS (Loss of Signal) akan semakin tinggi.
Gambar 6. Siapkan Kabel UTP
2.        Ukur sekitar 1 cm dari ujung kabel dan potonglah bagian luar dari kabel perlahan secara memutar. Dalam proses ini berhati-hatilah karena kesalahan sedikit saja dapat membuat kabel kabel tipis 8 warna yang ada dibagian dalam kabel dapat putus, yang berarti kita harus mengulang lagi untuk memotong bagian luarnya.

3.        Setelah bagian luarnya kita potong, susunlah kabel-kabel warna warni tersebut dengan urutan sebagai berikut:
Urutan kabel pada Straight-through Cable sama untuk kedua ujungnya dengan urutan [Putih Orange - Orange - Putih Hijau - Biru - Putih Biru - Hijau - Putih Coklat - Coklat] lihat gambar berikut ini :
Gambar 7. Urutan Kabel Cross

4.    Setelah menyusunnya dengan rapi dan memastikan kalau ujung dari semua kabel rata (untuk memudahkan ketika memasukkannya kedalam konektor RJ-45, potonglah jika semua ujung belum rata), ambil konektor RJ-45-nya kemudian masukkan semua ujung kabel yang telah di susun dengan hati-hati kedalam lubang yang terdapat pada konektor RJ-45 tersebut. Pastikan semua kabel rata pada tiap ujung lempengan yang ada di dalam port. Karena satu saja dari kaki-kaki kabel tidak menyentuh pada lempengan tersebut maka kabel tidak akan berfungsi.
5.           Kemudian, masukkanlah konektor RJ-45 yang telah disatukan dengan kabel tersebut pada Crimping Tool dan tekan dengan penekanan yang cukup kuat, dan tahan beberapa detik untuk memastikan kaki pengunci pada konektor telah mengunci kabel dengan baik sehingga tidak goyang atau lepas. Lakukan hal yang sama pada ujung satu lagi.
Gambar 8. Proses Crimping
6.         Jika telah selesai, sekarang kita akan menggunakan network cable tester untuk menguji apakah kabel kita telah berfungsi dengan baik. Masukkan kedua ujung konektor pada masing-masing port untuk RJ-45 pada tester, kemudian hidupkan testernya, perhatikan kedua bagian lampu indikator (yang biasanya masing-masing berjumlah 8 lampu plus 1 lampu indikator untuk grounding). Jika kabel dalam status yang bagus, lampu-lampu tersebut akan hidup berurutan sesuai dengan urutan nomornya (kecuali jika sedang menguji kabel cross dimana urutannya berbeda – lihat langkah :
Gambar 9. Testing Menggunakan Cable Tester
7.        Jika semua langkah tidak menemui masalah/berjalan dengan baik maka proses pembuatan/perakitan kabel jaringan telah selesai dan kabel siap untuk digunakan. Cobakan kabel dengan menghubungkan dengan dua buah komputer yang bisa membaca kabel cross maupun straight.
Gambar 10. Menghubungkan Dua Komputer

Gambar 11. Testing Ping

»»  Selengkapnya...
 
;