search
HomeBackend DevelopmentPHP ProblemHow to create a project using openPNE

I don’t know if you have used openPNE. In fact, we can use openPNE to create projects. Today we will introduce the method of creating a project in openPNE. You can refer to it if necessary.

How to create a project using openPNE

Find the php command under the cmd command prompt
Open "My Computer"->"Properties"->"Advanced "->"Environment Variables"->"System Variables"->"path", edit its value, and add the following path address in front

:

D:\wamp\bin\php\php5.3.0;   ===========php编译安装目录

Place php. ini to the C:\Windows directory

Simple building program for symfony

Extract the downloaded symfony compressed package to the www folder and name it symfony

Command line input

e:打开E盘根目录
cd..\..    ===========返回上两级,或打开指定目录
cd wamp\www\symfony    ===========打开指定目录
php data\bin\symfony -V    ===========查询symfony版本信息
php data\bin\symfony generate:project newProject    ===========在www\symfony文件夹下生成一个名叫newProject的新项目
php data\bin\symfony generate:app myApp    ===========在该项目的APPS文件夹下生成一个名叫myApp新程序
php data\bin\symfony generate:module myApp myModule    ===========在myApp程序文件夹下建立一个名叫myModule的新模块

The symfony command called by php opens the directory where the symfony command is stored relative to the current directory

The action method written in the action class and the access path to the corresponding template mymodule module name myAction action method name

OpenPNE installation

Extract the downloaded compressed package to the server directory

Look for ProjectConfiguration..php. The sample is renamed to ProjectConfiguration..php

Apache service opens the rewrite module

Open the folder where openPNE is located under the cmd command and enter

php symfony openpne:install

APC extension of PHP: if necessary Download php_apc.dll in 115 to the wamp\bin\php\php5.3.0\ext directory

Open the php_apc of the php extension, open php.ini, find extension=php_apc.dll and add in the next line

apc.enabled=0
apc.shm_segments=0
apc.enable_cli=0

If there is a cache folder in the root directory, clear the contents in the cache

Create a program

cmd input

php symfony opGenerate:plugin opVotePlugin    ===========创建一个vote插件程序
php symfony opGenerate:app opVotePlugin pc_frontend    ===========为vote插件程序创建电脑前台文件夹
php symfony opGenerate:module opVotePlugin pc_frontend vote    ===========在vote插件程序电脑前台文件夹内创建vote模块
php symfony cc    ===========清除一次缓存

action actions and access rights

Create an opVotePluginVoteActions..php file in the plugins\opVotePlugin\lib\actions directory

Write the class class opVotePluginVoteActions sfActions{}## in the file

#Then the class in the opVotePlugin\apps\pc_frontend\modules\vote\actions\actions..php file inherits the class just written

voteActions opVotePluginVoteActions{}

Not only the computer frontend In the pc_frontend folder, all mobile computer front and back module actions under opVotePlugin\apps can inherit this class to implement one class to manage multiple front ends

Create plugins\opVotePlugin\apps\pc_frontend\modules\vote\ config\security.yml file and enter

all:

is_secure: on

credentials: SNSMember

means that this module requires verification and only members can access it

Write an action in the opVotePluginVoteActions class

executeShow(sfWebRequest){}

Then create plugins\opVotePlugin\apps\pc_frontend\modules\vote\templates\showSuccess.php

Execute the command php symfony cc once

Create a database table

Create the plugins/opVotePlugin/config/doctrine/schema.yml file and enter


options:
  charset: utf8

VoteQuestion:
  actAs: [Timestampable]
  columns:
    id: { type: (4), primary: , autoincrement:  }
    member_id: { type: (4), notnull:  }
    title: { type: (140), notnull:  }
    body: { type:  }
  relations:
    Member: { onDelete: cascade }

VoteQuestionOption:
  columns:
    id: { type: (4), primary: , autoincrement:  }
    vote_question_id: { type: (4), notnull:  }
    body: { type: (140), notnull:  }
  relations:
    VoteQuestion: { onDelete: cascade, foreignAlias: VoteQuestionOptions }

VoteAnswer:
  actAs: [Timestampable]
  columns:
    id: { type: (4), primary: , autoincrement:  }
    member_id: { type: (4), notnull:  }
    vote_question_id: { type: (4), notnull:  }
    vote_question_option_id: { type: (4), notnull:  }
    body: { type:  }
  relations:
    Member: { onDelete: cascade }
    VoteQuestion: { onDelete: cascade, foreignAlias: VoteAnswers }
    VoteQuestionOption: { onDelete: cascade, foreignAlias: VoteAnswers }

means that the three tables vote_question, vote_question_option, and vote_answer have been created respectively. The relations represent the establishment of foreign key relationships.

At this time, executing the command php symfony openpne:install will reinstall openPNE and create the previous After three tables

execute php symfony doctrine:build --all --and-load again to reinsert the data

routing rules

create plugins/opVotePlugin/lib/routing/opVotePluginFrontendCollection..php

Enter

<?php
 opVotePluginFrontendRouteCollection  sfRouteCollection
{
  __construct( )
  {
    parent::__construct();
->routes = (
      &#39;vote_list&#39; =>  sfRequestRoute(    
        &#39;/vote&#39;,                                    (&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;index&#39;),            (&#39;sf_method&#39; => (&#39;get&#39;))
      ),
      &#39;vote_new&#39; =>  sfRequestRoute(
        &#39;/vote/new&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;new&#39;),
(&#39;sf_method&#39; => (&#39;get&#39;))
      ),
      &#39;vote_create&#39; =>  sfRequestRoute(
        &#39;/vote/create&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;create&#39;),
(&#39;sf_method&#39; => (&#39;post&#39;))
      ),
      &#39;vote_edit&#39; =>  sfDoctrineRoute(
        &#39;/vote/edit/:id&#39;,            (&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;edit&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_update&#39; =>  sfDoctrineRoute(
        &#39;/vote/update/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;update&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_show&#39; =>  sfDoctrineRoute(
        &#39;/vote/show/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;show&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_post&#39; =>  sfDoctrineRoute(
        &#39;/vote/post/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;post&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_delete_confirm&#39; =>  sfDoctrineRoute(
        &#39;/vote/delete/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;deleteConfirm&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_delete&#39; =>  sfDoctrineRoute(
        &#39;/vote/delete/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;delete&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
     &#39;vote_nodefaults&#39; =>  sfRoute(
        &#39;/vote/*&#39;,
(&#39;module&#39; => &#39;default&#39;, &#39;action&#39; => &#39;error&#39;)
      ),
    );
  }
}
?>

Create plugins/opVotePlugin/apps/pc_frontend/config/routing.yml

Enter

vote:
: opVotePluginFrontendRouteCollection
  options: { name: vote }

Specify which class to set routing rules

Enter the command php symfony cc

Enter the command php symfony app:routes pc_frontend to check whether the route is set successfully

It is also possible not to create the opVotePluginFrontendCollection..php and routing.yml files. Access will be based on the default route.

Recommended learning:

php video tutorial

The above is the detailed content of How to create a project using openPNE. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.