¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

PHP/Php Framework

Last-modified: 2018-11-14 (¿å) 15:23:56 (2153d)
Top / PHP / Php Framework

PHP

¡ÖPhp Framework¡×¤È¤Ï¡¢Ruby on Rails¤ò¼è¤êÆþ¤ì¤¿PHP¤Î¥ª¡¼¥×¥ó¥½¡¼¥¹ ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Ç¤¹¡£
Ruby on Rails¤ÎÍøÅÀ¤ò³è¤«¤·¤¿Web¥¢¥×¥ê³«È¯¤òPHP¤Ç³èÍѤǤ­¤ë¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Ç¤¹¡£

Php FrameworkÍøÍѤˤè¤ë¥á¥ê¥Ã¥È

  1. »È¤¤´·¤ì¤¿PHP¤òÍøÍѤ·¤Æ³«È¯¤¬¹Ô¤¨¡¢Smarty¡¦PEAR¤Ê¤É¤â´Êñ¤ËÍøÍѲÄǽ
  2. O/R¥Þ¥Ã¥Ô¥ó¥°¤Ë¤è¤ë´ÊÊؤʥǡ¼¥¿¥Ù¡¼¥¹¥¢¥¯¥»¥¹
  3. migration¤Ë¤è¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¹½À®¤Î¥Ð¡¼¥¸¥ç¥ó´ÉÍý¡¢ËÜÈÖÈ¿±Ç¤¬²Äǽ
  4. ¥Ð¥Ã¥¯¥¨¥ó¥É¤È¥Õ¥í¥ó¥È¥¨¥ó¥É¤òÍưפ˳«È¯²Äǽ
  5. ³«È¯´Ä¶­¤òdevelopment(¥í¡¼¥«¥ëPC), test(¥Æ¥¹¥È¥µ¥¤¥È¤ä¥Æ¥¹¥È¼Â¹Ô), production(ËÜÈÖ¥µ¥¤¥È)¤Èʬ¤±¤é¤ì¤ë¤Î¤Ç¡¢ËÜÈÖDB¤Ë±Æ¶Á¤òÍ¿¤¨¤º³«È¯²Äǽ
  6. ¤³¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Ë´·¤ì¤Æ¤ª¤¯¤È¡¢Ruby on Rails¤Î¥×¥í¥¸¥§¥¯¥È¤âÍý²ò¤·¤ä¤¹¤¯¤Ê¤ë

Php FrameworkÍý²ò¤È³èÍѤΤ¿¤á¤Î¥¹¥Æ¥Ã¥×

  1. ¸ø¼° ¥È¥Ã¥×¥Ú¡¼¥¸¤ò»²¾È
  2. ¸ø¼° ¥Á¥å¡¼¥È¥ê¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¡¢¥í¡¼¥«¥ëPC¤ÎXAMPP¾å¤ÇÆ°¤«¤·¤Æ¤ß¤ë
  3. ¤½¤ÎºÝ¤Ëʬ¤«¤ê¤Ë¤¯¤¤ÅÀ¤Ï¡¢¤³¤Î¥Ú¡¼¥¸Æâ¤ÎÊ䭤dzÎǧ
  4. ɬÍפ˱þ¤¸¤ÆRuby on Rails¤â³Ø½¬¤·¤Æ»²¹Í¤È¤¹¤ë¡£

¥ê¥ó¥¯

¥Á¥å¡¼¥È¥ê¥¢¥ë¤Î¥í¡¼¥«¥ëPCÀܳÀè

¥Õ¥í¥ó¥È¥¨¥ó¥É
http://localhost/chiral_fw_sample/samples/application/app/apps_web/frontend/

¥Ð¥Ã¥¯¥¨¥ó¥É
http://localhost/chiral_fw_sample/samples/application/app/apps_web/backend/

¢¨¥Ñ¥¹Ì¾¤ÏŬµ¹ÊѤ¨¤Æ¤¯¤À¤µ¤¤

¥Á¥å¡¼¥È¥ê¥¢¥ëÊä­¡§´°À®¸å¤Î²èÌÌ

PhpFrameworkTutorialFrontendBbsList.gif

¼¡¤Î¹½À®¤Î¥Ç¡¼¥¿¤òÆþ¤ì¤¿¡¢´°À®¸å¤Î·Ç¼¨Èĥꥹ¥È²èÌ̤Ǥ¹¡£

¥¿¥¤¥È¥ë£± bbsËÜʸ£±
  ¨§ ¥³¥á¥ó¥È£±
  ¨¦ ¥³¥á¥ó¥È£²

¥¿¥¤¥È¥ë£² bbsËÜʸ£²
  ¨¦ ¥³¥á¥ó¥È£³

´ÉÍý²èÌ̤Îbbs°ìÍ÷¤Ç¤¹¡£

PhpFrameworkTutorialBackendBbsList.gif

´ÉÍý²èÌ̤Îcomment°ìÍ÷¤Ç¤¹¡£

PhpFrameworkTutorialBackendCommentList.gif

¥Á¥å¡¼¥È¥ê¥¢¥ëÊä­¡§¥Æ¡¼¥Ö¥ë¤Î´ØÏ¢À­

bbs¥Æ¡¼¥Ö¥ë
    id
    subject     ... ·Ç¼¨ÆâÍÆ¥¿¥¤¥È¥ë
    body        ... ·Ç¼¨ÆâÍÆËÜʸ
    created_at
    updated_at
    'relations' => array(
        'Comment' => 'item',   ... »Ò¶¡¤Ïcomment¥Æ¡¼¥Ö¥ë¤Ç¤¹¡£
                                   ¿Æ£±¤Ä¤ËÂФ·¤Æ»Ò¶¡¤ÏÊ£¿ô»ý¤Æ¤Þ¤¹¡£
                                   ¿Æ¡§»Ò ¡á £±¡§£Î¤Î´Ø·¸¤Ç¤¹¡£
    )
    function after_delete() 
    {
        $cnt = $this->delete_items('Comment'); ... ËÜʸ¤òºï½ü¤·¤¿¤È¤­¤Ï¡¢»Òã¤Î¥³¥á¥ó¥È¤âºï½ü
    }
comment¥Æ¡¼¥Ö¥ë
    id
    bbs_id      ... ¿Æ(bbs)¤Îid¤ÇɳÉÕ¤±
    body        ... ¥³¥á¥ó¥ÈËÜʸ
    created_at
    updated_at
    'relations' => array(
        'Bbs' => 'header',     ... ¿Æ¤Ïbbs¥Æ¡¼¥Ö¥ë¤Ç¤¹¡£
                                   »Ò¶¡£±¤Ä¤ËÂФ·¤Æ¿Æ¤Ï£±¤Ä¤À¤±¤Ç¤¹¡£
    )

¥Á¥å¡¼¥È¥ê¥¢¥ëÊä­¡§·Ç¼¨Èĥꥹ¥È¤Î¥Ó¥å¡¼¤ò½ñ¤­´¹¤¨¤ë¤¢¤¿¤ê

app/apps/frontend/views/bbs/list.html

<h2><?php echo Application_Text::get('TITLE_LIST',
    array('name' => Fw_Record_Config::tablename('Bbs'))); ?></h2>
                ¢¬others/texts/Application_Text_Japanese.php¤ÇÄêµÁ¤·¤Æ¤¤¤ë
                  ÈÆÍÑÆüËܸì¥Õ¥©¡¼¥Þ¥Ã¥È¤Ë¹ç¤ï¤»¤Æ"{name}°ìÍ÷"¤Èɽ¼¨¤·¤Þ¤¹¡£
                  'name'¤ÏFw_Record_Config::tablename('Bbs')¤È¤¤¤¦¥Æ¡¼¥Ö¥ëɽ¼¨Ì¾¤òÅϤ·¤Þ¤¹¡£
                  ¥Æ¡¼¥Ö¥ëɽ¼¨Ì¾¤Ïcommon/models/Bbs.php¤ÇÄêµÁ¤·¤Þ¤¹¡£

<?php echo $this->link(Application_Text::get('LINK_ADD'), array('action' => 'edit')); ?><br />
                  ¢¬link(ɽ¼¨Ì¾, Èô¤ÓÀè)
                    ¤³¤³¤Ç¤ÏÈô¤ÓÀè¤Ë¼«¿È¤ÈƱ¤¸¥³¥ó¥È¥í¡¼¥é¡¼(bbs)¤Ç¡¢edit_action¤òÅϤ·¤Æ¤¤¤Þ¤¹¡£

<?php $this->output_pager_link($this->pager, $this->pager_params); ?>
             ¢¬pager¤ò»ÈÍѤ¹¤ë¤È¤­¡¢¤³¤Î¤è¤¦¤ËÀë¸À¤·¤Þ¤¹¡£

<table border=1>
  <tr>
    <td><?php echo Fw_Record_Config::columnname('Bbs','id');?></td>
    <td><?php echo Fw_Record_Config::columnname('Bbs','subject');?></td>
    <td><?php echo Fw_Record_Config::columnname('Bbs','body');?></td>
    <td><?php echo Fw_Record_Config::columnname('Bbs','created_at');?></td>
    <td><?php echo Fw_Record_Config::columnname('Bbs','updated_at');?></td>
  </tr>
  <?php foreach($this->pager->page_list() as $row){ ?>
        ¢¬pager¤ò»ÈÍѤ¹¤ë¤È¤­¤Î¥ë¡¼¥×¤Ç¤¹¡£
  <tr>
    <td><?php echo ht($row->id); ?></td>
    <td><?php echo ht($row->subject); ?></td>
    <td><?php echo ht($row->body); ?></td>
    <td><?php echo ht($row->created_at); ?></td>
    <td><?php echo ht($row->updated_at); ?></td>
    <td>
      <?php echo $this->link(Application_Text::get('LINK_EDIT'),
          array('action' => 'edit', 'id' => $row->id())); ?>
                  ¢¬link(ɽ¼¨Ì¾, Èô¤ÓÀè)
                    ¤³¤³¤Ç¤ÏÈô¤ÓÀè¤Ë¼«¿È¤ÈƱ¤¸¥³¥ó¥È¥í¡¼¥é¡¼(bbs)¤Ç¡¢edit_action
                    ¤Ë²Ã¤¨¤Æid¤òÅϤ·¤Æ¤¤¤Þ¤¹¡£
    </td>
    <td>
      <?php echo $this->link(Application_Text::get('LINK_DELETE'),
          array('action' => 'delete', 'id' => $row->id()),
          array('confirm' => Application_Text::get('CONFIRM_DELETE'))); ?>
                         ¢¬link(ɽ¼¨Ì¾, Èô¤ÓÀè, ºï½ü³Îǧ¥À¥¤¥¢¥í¥°)
    </td>
  </tr>
  <tr>
    <td colspan="7">

      <h3><?php echo Application_Text::get('TITLE_LIST',
          array('name' => Fw_Record_Config::tablename('Comment'))); ?></h3>

      <?php echo $this->link(Application_Text::get('LINK_ADD'),
          array('controller' => 'comment', 'action' => 'edit', 'bbs_id' => $row->id())); ?><br />
                     ¢¬link(ɽ¼¨Ì¾, Èô¤ÓÀè)
                       Èô¤ÓÀè¤Ïcontroller, action, ¥Ñ¥é¥á¡¼¥¿¤òÀßÄꤷ¤Þ¤¹¡£
                       ¥Ñ¥é¥á¡¼¥¿¤Ï¥³¥ó¥È¥í¡¼¥é¦¤Ç$_REQUEST['bbs_id']¤È¤¹¤ë¤È¼èÆÀ¤Ç¤­¤Þ¤¹¡£
                           if (isset($_REQUEST['bbs_id']) && $_REQUEST['bbs_id']) {
                               $this->comment->bbs_id = $_REQUEST['bbs_id'];
                           }

      <table border=1>
        <tr>
          <td><?php echo Fw_Record_Config::columnname('Comment','id');?></td>
          <td><?php echo Fw_Record_Config::columnname('Comment','body');?></td>
          <td><?php echo Fw_Record_Config::columnname('Comment','created_at');?></td>
          <td><?php echo Fw_Record_Config::columnname('Comment','updated_at');?></td>
                         ¢¬¤½¤ì¤¾¤ì¥Õ¥£¡¼¥ë¥Éɽ¼¨Ì¾¤ò½ÐÎϤ·¤Þ¤¹¡£
                           ÄêµÁ¾ì½ê¤Ïcommon/models/Comment.php¤Î¼¡¤ÎÄ̤ê¤Ç¤¹¡£
Fw_Record_Config::set('Comment', array(
    'tablename' => 'comment',         ... ¥Æ¡¼¥Ö¥ëɽ¼¨Ì¾
    'columnnames' => array(
        'id' => 'id',                 ... ¥Õ¥£¡¼¥ë¥Éɽ¼¨Ì¾
        'bbs_id' => 'bbs_id',         ... ¡·
        'body' => 'body',             ... ¡·
        'created_at' => 'created_at' ,... ¡·
        'updated_at' => 'updated_at' ,... ¡·
    ),
    'relations' => array(
        'Bbs' => 'header',
    ),

        </tr>
        <?php foreach($row->r('Comment')->findall(array('order' => 'id')) as $row_comment){ ?>
               ¢¬¿Æ¥ª¥Ö¥¸¥§¥¯¥È¤¬»ý¤Ã¤Æ¤¤¤ë¤¹¤Ù¤Æ¤Î»Ò¤òforeach¤Ç¥ë¡¼¥×¤µ¤»¤ë¤³¤Îɽµ­Ë¡¤Ï¤½¤Î¤Þ¤Þ³Ð¤¨¤Þ¤·¤ç¤¦¡£

        <tr>
          <td><?php echo ht($row_comment->id); ?></td>
          <td><?php echo ht($row_comment->body); ?></td>
          <td><?php echo ht($row_comment->created_at); ?></td>
          <td><?php echo ht($row_comment->updated_at); ?></td>
          <td>
            <?php echo $this->link(Application_Text::get('LINK_EDIT'),
                array('controller' => 'comment', 'action' => 'edit', 'id' => $row_comment->id())); ?>
          </td>
          <td>
            <?php echo $this->link(Application_Text::get('LINK_DELETE'),
                array('controller' => 'comment', 'action' => 'delete', 'id' => $row_comment->id()),
                array('confirm' => Application_Text::get('CONFIRM_DELETE'))); ?>
          </td>
        </tr>
        <?php } ?>
      </table>
    </td>
  </tr>


  <?php } ?>
</table>

¥Á¥å¡¼¥È¥ê¥¢¥ëÊä­¡§´ÉÍý²èÌ̥ȥåפΥӥ塼¤ò½ñ¤­´¹¤¨¤ë¤¢¤¿¤ê

½ñ¤­´¹¤¨¸å¤Î´ÉÍý²èÌ̥ȥå×

PhpFrameworkTutorialBackendTop.gif
app/apps/backend/views/_layouts/application.html

<html>
<head>
<?php echo $this->get('_common/head.html'); ?>
      ¢¬¥¤¥ó¥¯¥ë¡¼¥É¤Ï¤³¤Î¤è¤¦¤Ëµ­½Ò¤·¤Þ¤¹¡£
        £±¸Ä¾å¤Î¥Ç¥£¥ì¥¯¥È¥ê¤¬¥Ù¡¼¥¹¤Ç¤¹¡£
</head>
<body>
  <h1>Sample Application Backend</h1>

  <div style="background-color: #aa9999;">
<?php if(Application_Util::get_auth()->is_login()){?>
  Login ID: <?php echo h(Application_Util::get_auth()->info()->loginid); ?>
<?php }?>
  </div>
  ¢¬¥í¥°¥¤¥ó¤·¤Æ¤¤¤ë¤È¤­¤Ï¥í¥°¥¤¥óID¤òɽ¼¨

  ¢­¥í¥°¥¤¥ó¤·¤Æ¤¤¤ë¤È¤­¤Ï¥í¥°¥¢¥¦¥È²èÌ̤ؤΥê¥ó¥¯¤òɽ¼¨
<?php if(Application_Util::get_auth()->is_login()){?>
  <div style="background-color: #cccccc;">
    <?php echo $this->link_dynamic(
        'Logout',
        array('controller' => 'auth', 'action' => 'logout',),
        array('class' => 'link_dynamic_link'),
        array('class' => 'link_dynamic_font')); ?> 
        ¢¬$this->link_dynamic()¤òÍѤ¤¤ë¤È¥µ¥¤¥ÈÆâÀäÂХѥ¹¤Î¥ê¥ó¥¯¤¬ºî¤é¤ì¤Þ¤¹¡£°ú¿ô¤Ï¡¢
            ɽ¼¨Ì¾
            Èô¤ÓÀè
            ¥ê¥ó¥¯¤Îcss¤Ê¤É°À­
            ¥Õ¥©¥ó¥È¤Îcss¤Ê¤É°À­¡© ... »È¤ï¤ì¤Æ¤¤¤Ê¤¤¤è¤¦¤Ç¤¹

          ¼¡¤Î¤è¤¦¤Ë¥Ö¥é¥¦¥¶¤ËÅϤê¤Þ¤¹¡£
            <a class="link_dynamic_link"
             href="/chiral_fw_sample/samples/application/app/apps_web/backend/auth/logout/">
             Logout</a> 

  </div>
<?php }?>

    <?php echo $this->link_dynamic(
        Fw_Record_Config::tablename('Bbs'),
        array('controller' => 'bbs', 'action' => 'list',),
        array('style' => 'color:#2222bb'),
        array('style' => 'color:#22aa22')); ?>
           ¢¬¼¡¤Î¤è¤¦¤Ë¥Ö¥é¥¦¥¶¤ËÅϤê¤Þ¤¹¡£
              <a style="color:#2222bb"
               href="/chiral_fw_sample/samples/application/app/apps_web/backend/bbs/list/">
               bbs</a>

    <?php echo $this->link_dynamic(
        Fw_Record_Config::tablename('Comment'),
        array('controller' => 'comment', 'action' => 'list',),
        array('style' => 'color:#2222bb'),
        array('style' => 'color:#22aa22')); ?>
           ¢¬¼¡¤Î¤è¤¦¤Ë¥Ö¥é¥¦¥¶¤ËÅϤê¤Þ¤¹¡£
                <a style="color:#2222bb"
                 href="/chiral_fw_sample/samples/application/app/apps_web/backend/comment/list/">
                 comment</a>

<?php if(Fw_Controller_Flash::exists('notice')){?>
<div class="notice"><?php echo Fw_Controller_Flash::get('notice')?></div>
<?php }?>
¢¬¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤«¤é¤ÎNotice¤¬Í­¤ì¤Ðɽ¼¨¤µ¤ì¤Þ¤¹¡£

<div>
  <?php echo $this->contents; ?>
</div>
¢¬¥³¥ó¥È¥í¡¼¥é¡¼¤ÇÀ¸À®¤·¤¿ËÜʸ¤Ç¤¹¡£

<?php
$trace_string = Fw_Controller_Debug::trace_string();
echo $trace_string;
?>
¢¬
develop´Ä¶­¤Ç¤Î¥È¥ì¡¼¥¹½ÐÎϤǤ¹¡£

</body>
</html>

¥Ó¥å¡¼µ­½ÒÎã

Ruby on Rails¥Æ¥ó¥×¥ì¡¼¥ÈÎã(³ÈÄ¥»Ò¤Ï.rhtml)

<% Ruby¥×¥í¥°¥é¥à %>
<%= ¥¿¥°¤ò½ÐÎϤ¹¤ëRuby¥×¥í¥°¥é¥à %>
<%=h ËÜʸ¤ò½ÐÎϤ¹¤ëRuby¥×¥í¥°¥é¥à %>

Php FrameworkÄ̾ï¥Æ¥ó¥×¥ì¡¼¥ÈÎã(³ÈÄ¥»Ò¤Ï.html)

<?php PHP¥×¥í¥°¥é¥à; ?>
<?php echo ¥¿¥°PHPʸ»úÎó; ?>
<?php echo ht(ËÜʸPHPʸ»úÎó); ?>

<?php echo ¥¿¥°PHPʸ»úÎó; ?>¤Ç¡Ö¥¿¥°PHPʸ»úÎó¡×¤Ë¤è¤¯½ñ¤«¤ì¤ë¥Õ¥ì¡¼¥º

µ­½ÒÆâÍƵ­½ÒÎã
members¥Æ¡¼¥Ö¥ë¤Îuid¥Õ¥£¡¼¥ë¥Éɽ¼¨Ì¾Fw_Record_Config::columnname('Member','uid')
¥Þ¥Ã¥Ô¥ó¥°¤µ¤ì¤¿member¥ª¥Ö¥¸¥§¥¯¥È¤Îuid¥Õ¥£¡¼¥ë¥ÉÃͤòhtml¥¨¥¹¥±¡¼¥×¤·¤¿ÃÍht($this->member->uid)
ɽ¼¨Ì¾ÇÛÎócareer_hash¤ò»²¾È¤·¤Æɽ¼¨$this->career_hash[ $this->member->career_id ]
member¥ª¥Ö¥¸¥§¥¯¥Èname¥Õ¥£¡¼¥ë¥É¤ËÆþÎϤ¹¤ë¥Æ¥­¥¹¥È¥Ü¥Ã¥¯¥¹(Éý50)$this->record("textbox", "member", "name", array('size' => '50')
member¥ª¥Ö¥¸¥§¥¯¥Èannounce¥Õ¥£¡¼¥ë¥É¤ËÆþÎϤ¹¤ë¥Æ¥­¥¹¥È¥¨¥ê¥¢$this->record("textarea", "member", "announce", array('rows' => '20', 'cols' => '50'))
member¥ª¥Ö¥¸¥§¥¯¥Èname¥Õ¥£¡¼¥ë¥É¤ËÆþÎϤ¹¤ëÁªÂò$this->record("select", "member", "sex", $this->SEX_HASH, array(), array('include_blank' => true))
¥â¥Ç¥ë¤Ë¥Þ¥Ã¥Ô¥ó¥°¤µ¤ì¤Æ¤¤¤Ê¤¤¥Æ¥­¥¹¥È¥Ü¥Ã¥¯¥¹ ¥³¥ó¥È¥í¡¼¥é¤«¤é¤Ï$_REQUEST['point_up_down']¤Ç»²¾È$this->textbox("point_up_down", "", array('size' => '20', 'style' => 'text-align:right'))

Php Framework Smarty¥Æ¥ó¥×¥ì¡¼¥ÈÎã(³ÈÄ¥»Ò¤Ï.tpl)

{ * ¥³¥á¥ó¥È *}
{ Smarty¤ÎÀ©¸æʸ }
{ include file="info/_type_detail_`$content_type_id`.tpl" }