Zend Framework 튜토리얼의 애플리케이션 사용 예에 대한 자세한 설명
이 기사의 예에서는 Zend Framework 튜토리얼의 애플리케이션 사용법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 자세한 내용은 다음과 같습니다.
Zend_Application은 Zend Framework의 핵심 구성 요소입니다. Zend_Application은 Zend Framework 애플리케이션에 대한 기본 기능을 제공하며 프로그램의 진입점입니다. 주요 기능은 PHP 환경 로드 및 구성(자동 로드 포함)과 애플리케이션 부팅의 두 가지입니다.
일반적으로 Zend_Application 생성자는 구성 옵션을 통해 구성되지만 사용자 지정 방법을 사용하여 완전히 구성할 수도 있습니다. 아래에는 두 가지 사용 사례가 있습니다.
Zend_Application 구성 옵션
생성자:
/** * Constructor * * Initialize application. Potentially initializes include_paths, PHP * settings, and bootstrap class. * * @param string $environment * @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options * @throws Zend_Application_Exception When invalid options are provided * @return void */ public function __construct($environment, $options = null) { $this->_environment = (string) $environment; require_once 'Zend/Loader/Autoloader.php'; $this->_autoloader = Zend_Loader_Autoloader::getInstance(); if (null !== $options) { if (is_string($options)) { $options = $this->_loadConfig($options); } elseif ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (!is_array($options)) { throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array'); } $this->setOptions($options); } }
Zend_Application 구성 방법
1. 구성 파일 사용
2. >
// Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->bootstrap() ->run();
<?php class Zend_Application { /** * Constructor * * Initialize application. Potentially initializes include_paths, PHP * settings, and bootstrap class. * * @param string $environment * @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options * @throws Zend_Application_Exception When invalid options are provided * @return void */ public function __construct($environment, $options = null) { $this->_environment = (string) $environment; require_once 'Zend/Loader/Autoloader.php'; $this->_autoloader = Zend_Loader_Autoloader::getInstance(); if (null !== $options) { if (is_string($options)) { $options = $this->_loadConfig($options); } elseif ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (!is_array($options)) { throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array'); } $this->setOptions($options); } } /** * Retrieve current environment * * @return string */ public function getEnvironment() { return $this->_environment; } /** * Retrieve autoloader instance * * @return Zend_Loader_Autoloader */ public function getAutoloader() { return $this->_autoloader; } /** * Set application options * * @param array $options * @throws Zend_Application_Exception When no bootstrap path is provided * @throws Zend_Application_Exception When invalid bootstrap information are provided * @return Zend_Application */ public function setOptions(array $options) { if (!empty($options['config'])) { if (is_array($options['config'])) { $_options = array(); foreach ($options['config'] as $tmp) { $_options = $this->mergeOptions($_options, $this->_loadConfig($tmp)); } $options = $this->mergeOptions($_options, $options); } else { $options = $this->mergeOptions($this->_loadConfig($options['config']), $options); } } $this->_options = $options; $options = array_change_key_case($options, CASE_LOWER); $this->_optionKeys = array_keys($options); if (!empty($options['phpsettings'])) { $this->setPhpSettings($options['phpsettings']); } if (!empty($options['includepaths'])) { $this->setIncludePaths($options['includepaths']); } if (!empty($options['autoloadernamespaces'])) { $this->setAutoloaderNamespaces($options['autoloadernamespaces']); } if (!empty($options['autoloaderzfpath'])) { $autoloader = $this->getAutoloader(); if (method_exists($autoloader, 'setZfPath')) { $zfPath = $options['autoloaderzfpath']; $zfVersion = !empty($options['autoloaderzfversion']) ? $options['autoloaderzfversion'] : 'latest'; $autoloader->setZfPath($zfPath, $zfVersion); } } if (!empty($options['bootstrap'])) { $bootstrap = $options['bootstrap']; if (is_string($bootstrap)) { $this->setBootstrap($bootstrap); } elseif (is_array($bootstrap)) { if (empty($bootstrap['path'])) { throw new Zend_Application_Exception('No bootstrap path provided'); } $path = $bootstrap['path']; $class = null; if (!empty($bootstrap['class'])) { $class = $bootstrap['class']; } $this->setBootstrap($path, $class); } else { throw new Zend_Application_Exception('Invalid bootstrap information provided'); } } return $this; } /** * Retrieve application options (for caching) * * @return array */ public function getOptions() { return $this->_options; } /** * Is an option present? * * @param string $key * @return bool */ public function hasOption($key) { return in_array(strtolower($key), $this->_optionKeys); } /** * Retrieve a single option * * @param string $key * @return mixed */ public function getOption($key) { } /** * Merge options recursively * * @param array $array1 * @param mixed $array2 * @return array */ public function mergeOptions(array $array1, $array2 = null) { if (is_array($array2)) { foreach ($array2 as $key => $val) { if (is_array($array2[$key])) { $array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key])) ? $this->mergeOptions($array1[$key], $array2[$key]) : $array2[$key]; } else { $array1[$key] = $val; } } } return $array1; } /** * Set PHP configuration settings * * @param array $settings * @param string $prefix Key prefix to prepend to array values (used to map . separated INI values) * @return Zend_Application */ public function setPhpSettings(array $settings, $prefix = '') { foreach ($settings as $key => $value) { $key = empty($prefix) ? $key : $prefix . $key; if (is_scalar($value)) { ini_set($key, $value); } elseif (is_array($value)) { $this->setPhpSettings($value, $key . '.'); } } return $this; } /** * Set include path * * @param array $paths * @return Zend_Application */ public function setIncludePaths(array $paths) { $path = implode(PATH_SEPARATOR, $paths); set_include_path($path . PATH_SEPARATOR . get_include_path()); return $this; } /** * Set autoloader namespaces * * @param array $namespaces * @return Zend_Application */ public function setAutoloaderNamespaces(array $namespaces) { $autoloader = $this->getAutoloader(); foreach ($namespaces as $namespace) { $autoloader->registerNamespace($namespace); } return $this; } /** * Set bootstrap path/class * * @param string $path * @param string $class * @return Zend_Application */ public function setBootstrap($path, $class = null) { // setOptions() can potentially send a null value; specify default // here if (null === $class) { $class = 'Bootstrap'; } if (!class_exists($class, false)) { require_once $path; if (!class_exists($class, false)) { throw new Zend_Application_Exception('Bootstrap class not found'); } } $this->_bootstrap = new $class($this); if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) { throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper'); } return $this; } /** * Get bootstrap object * * @return Zend_Application_Bootstrap_BootstrapAbstract */ public function getBootstrap() { if (null === $this->_bootstrap) { $this->_bootstrap = new Zend_Application_Bootstrap_Bootstrap($this); } return $this->_bootstrap; } /** * Bootstrap application * * @param null|string|array $resource * @return Zend_Application */ public function bootstrap($resource = null) { $this->getBootstrap()->bootstrap($resource); return $this; } /** * Run the application * * @return void */ public function run() { $this->getBootstrap()->run(); } /** * Load configuration file of options * * @param string $file * @throws Zend_Application_Exception When invalid configuration file is provided * @return array */ protected function _loadConfig($file) { $environment = $this->getEnvironment(); $suffix = pathinfo($file, PATHINFO_EXTENSION); $suffix = ($suffix === 'dist') ? pathinfo(basename($file, ".$suffix"), PATHINFO_EXTENSION) : $suffix; switch (strtolower($suffix)) { case 'ini': $config = new Zend_Config_Ini($file, $environment); break; case 'xml': $config = new Zend_Config_Xml($file, $environment); break; case 'json': $config = new Zend_Config_Json($file, $environment); break; case 'yaml': case 'yml': $config = new Zend_Config_Yaml($file, $environment); break; case 'php': case 'inc': $config = include $file; if (!is_array($config)) { throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value'); } return $config; break; default: throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type'); } return $config->toArray(); } }

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PHP와 함께 ZendFramework 사용: 빠른 시작 가이드 ZendFramework는 강력하고 쉽게 확장 가능한 오픈 소스 PHP 기반 웹 애플리케이션 프레임워크입니다. ZendFramework에는 효율적인 웹 애플리케이션을 구축하는 데 도움이 되는 유용한 구성 요소가 많이 포함되어 있습니다. 이 기사에서는 PHP에서 ZendFramework를 사용하여 빠르게 시작하는 방법을 소개합니다. ZendFramewo 설치

ZendFramework 미들웨어를 통한 효율적인 데이터베이스 쿼리 구현 소개 개발 과정에서 데이터베이스 쿼리는 피할 수 없는 부분입니다. 효율적인 데이터베이스 쿼리는 시스템 성능과 사용자 경험을 크게 향상시킬 수 있습니다. ZendFramework는 강력한 데이터베이스 작업 기능을 갖춘 널리 사용되는 PHP 프레임워크입니다. 이 기사에서는 ZendFramework 미들웨어를 통해 효율적인 데이터베이스 쿼리를 구현하는 방법을 소개하고 해당 코드 예제를 제공합니다. 1. ZendF 이해

ZendFramework는 개발자가 확장 가능한 고성능 PHP 애플리케이션을 신속하게 구축하는 데 도움이 되는 강력한 개발 프레임워크입니다. 그 중 미들웨어는 ZendFramework의 중요한 개념으로, 전체 텍스트 검색 및 페이징 기능을 구현하는 데 도움을 줄 수 있습니다. 이 기사에서는 ZendFramework에서 미들웨어를 사용하여 이 두 가지 기능을 구현하는 방법을 소개하고 코드 예제를 제공합니다. 1. 전체 텍스트 검색 기능 전체 텍스트 검색은 최신 응용 프로그램의 일반적인 기능 중 하나입니다.

ZendFramework 미들웨어: 애플리케이션에 OAuth 및 OpenID 로그인 지원 추가 사용자 인증은 오늘날의 인터넷 애플리케이션에서 중요한 기능입니다. 더 나은 사용자 경험과 보안을 제공하기 위해 많은 애플리케이션은 OAuth 및 OpenID와 같은 타사 로그인 서비스를 통합하기로 선택합니다. ZendFramework에서는 미들웨어를 통해 애플리케이션에 OAuth 및 OpenID 로그인 지원을 쉽게 추가할 수 있습니다. 먼저 Ze를 설치해야 합니다.

ZendFramework 미들웨어: 이메일 알림 및 메시지 푸시 기능 제공 소개: 인터넷의 발전과 스마트폰의 인기로 인해 이메일 알림 및 메시지 푸시는 현대 소프트웨어 개발에서 일반적으로 사용되는 기능 중 하나가 되었습니다. ZendFramework에서는 미들웨어를 사용하여 이메일 알림 및 메시지 푸시 기능을 구현할 수 있습니다. 이 기사에서는 ZendFramework 미들웨어를 사용하여 이메일 알림 및 메시지 푸시를 구현하는 방법을 소개하고 해당 코드 예제를 제공합니다. 1. 준비 작업

ZendFramework는 확장 가능한 웹 애플리케이션을 구축하기 위한 많은 강력한 도구와 구성 요소를 제공하는 PHP 기반의 오픈 소스 프레임워크입니다. 이 기사에서는 ZendFramework의 미들웨어를 사용하여 웹 애플리케이션에 소셜 로그인 기능을 추가하는 방법을 소개합니다. 미들웨어는 요청이 애플리케이션에 들어오기 전이나 후에 실행되는 코드입니다. 이를 통해 개발자는 요청 처리 프로세스를 사용자 정의하고 확장할 수 있습니다. ZendFramework는 유연한 방법을 제공합니다.

ERP 시스템을 개발하기로 결정했다면 적합한 프레임워크를 선택하는 것이 중요합니다. 여기서는 ERP 시스템 개발에 더 적합한 프레임워크를 찾는 데 도움이 되도록 두 가지 PHP 프레임워크인 CodeIgniter와 ZendFramework를 비교해 보겠습니다. CodeIgniter와 ZendFramework는 널리 사용되는 PHP 프레임워크입니다. 둘 다 많은 기능을 제공하며 확장 및 유지 관리가 가능합니다. 그러나 이 두 프레임워크는 일부 측면에서 크게 다르며 일부 애플리케이션에 더 적합합니다.

ZendFramework 미들웨어: 애플리케이션에 Alipay 및 WeChat 결제 기능 추가 소개: 모바일 결제의 인기로 인해 Alipay 및 WeChat 결제는 많은 애플리케이션에서 필수적인 결제 방법이 되었습니다. 이 기사에서는 ZendFramework 미들웨어를 사용하여 Alipay 및 WeChat 결제 기능을 애플리케이션에 추가하는 방법을 소개합니다. 이 기사를 공부하면 미들웨어를 사용하여 결제 프로세스를 단순화하고 실제 프로젝트에 적용하는 방법을 배울 수 있습니다. 1. 준비 시작하기 전에,
