小编map*_*ith的帖子

如何使用Zend Framework 2使用Rest API

有人可以提供一个示例来使用Zend Framework 2中的第三方Rest API(例如:someurl).使用Zend_Rest在ZF1中这么简单.我不打算在我的应用程序中创建rest apis,只是消费第三方.

谢谢,

php api httprequest zend-framework2

6
推荐指数
1
解决办法
7219
查看次数

API 的 NODEJS Express 应用程序生成器

目前 Express JS Express 应用程序生成器支持基于 Express 版本使用或命令生成初始应用程序,或者我们将其称为Boilerplate,应用程序的结构如下,npx express-generatorexpress myapp

   app/public/
   app/public/javascripts/
   app/public/images/
   app/public/stylesheets/
   app/public/stylesheets/style.css
   app/routes/
   app/routes/index.js
   app/routes/users.js
   app/views/
   app/views/error.jade
   app/views/index.jade
   app/views/layout.jade
   app/app.js
   app/package.json
   app/bin/
   app/bin/www
Run Code Online (Sandbox Code Playgroud)

假设我只需要创建一个 API,因此在这种情况下我不需要在生成的应用程序中添加以下内容;

   app/public/javascripts/
   app/public/images/
   app/public/stylesheets/
   app/public/stylesheets/style.css
   ...
   app/views/
   app/views/error.jade
   app/views/index.jade
   app/views/layout.jade
Run Code Online (Sandbox Code Playgroud)

在这种情况下,是否有一种方法命令来生成仅指定给 API APP 的应用程序,包括类似body-parser或不包含我上面提到的不需要的文件和文件夹的包。

TIA。

javascript api node.js express

6
推荐指数
2
解决办法
5686
查看次数

数组到字符串转换.symfony2.7

我有一个下拉列表,其中包含实体旁边的实体+图标列表.但是当我提交表单时,我收到了这个错误:

在第38行的src\FLY\BookingsBundle\Resources\views\Post\show.html.twig中呈现模板("通知:数组到字符串转换")期间抛出异常.

CRITICAL - 未捕获的PHP异常Twig_Error_Runtime:"在"C:\ xampp\htdocs\Symfony\src\FLY\BookingsBundle/Resources/views /"中呈现模板("通知:数组到字符串转换")期间抛出异常发布/ show.html.twig"在第38行." 在C:\ xampp\htdocs\Symfony\app\cache\dev\classes.php第4795行.

class Post
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;


    /**
     * @var array
     *
     * @ORM\Column(name="compagny", type="array")
     */
    private $compagny;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }


    /**
     * Set compagny
     *
     * @param array $compagny
     * @return Post
     */
    public function setCompagny($compagny)
    {
        $this->compagny = $compagny;

        return $this;
    }

    /**
     * …
Run Code Online (Sandbox Code Playgroud)

php forms symfony twig

4
推荐指数
1
解决办法
2万
查看次数

Zend Framework调用另一个Controller Action

嗨,我有问题调用另一个控制器动作发送邮件,这是我的代码:

user.php的

public function followAction()
{
     $follow_id = $this->_getParam('id');
     $response = "<a href='javascript: void(0)'  class='i-wrap ig-wrap-user_social i-follow_small-user_social-wrap'><i class='i i-follow_small-user_social ig-user_social'></i>Stop Following</a>";

     notifyEmail()  ------> need to call Notity Controller with notifyEmail() Action along with           
                       params
     $this->_helper->json($response);  ----> return json response
}
Run Code Online (Sandbox Code Playgroud)

NotifyController.php

<?php

class NotifyController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */

    }

     public function index()
    {

    }

     public function notifyEmailAction()
    {
          // rest of email code goes here
    }

}
Run Code Online (Sandbox Code Playgroud)

感谢帮助!

php zend-framework

2
推荐指数
1
解决办法
2万
查看次数

如何在PHP中编码和解码多维数组?

可能重复:
PHP数组编码和解码:需要一个函数来编码和解码带有分隔符或数组本身的字符串或数组...

喜.我是php的新手.我需要在php中编写两个独立的函数来编码和解码多维数组.我附加了一个插件.......... encode.class.php ..............

<?php

/*-------------------------
Author: Jonathan Pulice
Date: July 26th, 2005
Name: JPEncodeClass v1
Desc: Encoder and decoder using patterns.
-------------------------*/

class Protector
{

    var $Pattern = "";
    var $PatternFlip = "";
    var $ToEncode = "";
    var $ToDecode = "";
    var $Decoded = "";
    var $Encoded = "";
    var $Bug = false;
    var $DecodePattern = "";

    function Debug($on = true)
    {
        $this->Bug = $on;
    }

    function Encode()
    {


        $ar = explode(":", $this->Pattern);
        $enc = $this->ToEncode;

        if ($this->Bug) …
Run Code Online (Sandbox Code Playgroud)

php arrays encoding decoding

0
推荐指数
1
解决办法
2万
查看次数

Symfony 3:Doctrine在数据库中存储NULL值

Symfony版本:3.1.3

我有一个像下面的控制器,

public function studentAddClassAction( $id, Request $request )
{
    $em     = $this->getDoctrine()->getManager();
    $student= new Student();

    // new class object and create the form
    $classes= $em->getRepository('PIE10Bundle:Classes')->findAll();
    $form   = $this->createForm(ClassType::class, $classes);
    $form->handleRequest($request);

    if( $form->isSubmitted() && $form->isValid() )
    {   
        $parent = $form['parent']->getData(); // the parentID
        $cName  = $form['class']->getData();
        $classID= $cName->getId(); // the classID

        //insert new row to the student table
        $student->setParentId( $parent );
        $student->setClassId( $classID );
        $student->setUserId( $id );

        $em->persist($student);
        $em->flush();

        $this->addFlash('notice',
                        'Student Updated');

        return $this->redirectToRoute('user_students');
    }
    // some other code
} …
Run Code Online (Sandbox Code Playgroud)

php symfony-forms symfony doctrine-orm

0
推荐指数
1
解决办法
419
查看次数