-
Hiển thị 101-125 của 256 tin nhắn. Mạch tin nhắnĐã gửi cách đây 5462 ngày
5. Define test data Fisrt of all, we may recognize YAML, read more in the: http://www.yaml.org/ Note: There is no need to define values for the created_at and updated_at columns, since symfony knows how to fill them by default
Đã gửi cách đây 5462 ngày4. Redefine the default homepage Open the routing configuration file of the frontend application, found in askeet/apps/frontend/config/routing.yml and locate the homepage: section. Change it to: homepage:
url: / param: { module: question, action: list }
Đã gửi cách đây 5462 ngày3. A few word about environment These two PHP scripts - frontend_dev.php and index.php - are called front controllers, and all the requests to the application are handled by them. You can find them in the askeet/web/ directory. As a matter of fact, the index.php file should be named frontend_prod.php, but as frontend is the first application that you created, symfony deduced that you probably wanted it to be the default application and renamed it to index.php, so that you can see your application in the production environment by just requesting. Note: Remember to always clear the cache when you add some classes or when you change some configuration files to see the result in the production environment
Đã gửi cách đây 5462 ngày2. Change the layout In application of the decorator design pattern the content of the template called by an action is integrated into a global template, or layout. So what is decorator design pattern? In object-oriented programming, the decorator pattern is a desing pattern that allows news/ additional behaviour tobe added to an existing object dynamically. We can read more about this in the: http://en.wikipedia.org/wiki/Decorator_pattern In this project, open the default layout (located in askeet/apps/frontend/templates/layout.php) and change it to the following Note: We created two stylesheets (main.css and layout.css). Copy them into your askeet/web/css/ directory and edit your frontend/config/view.yml to change the autoloaded stylesheets: stylesheets: [main, layout]
Đã gửi cách đây 5462 ngàyChappter 03: Drive into the MVC Architecture 1. The MVC Model - What is the MVC? Model-View-Controller (MVC) is an architecture pattern used in software enginerring. The pattern isolates business logi from input and presentation, permitting independent development, testing and maintenance of each. - If the code concerns data manipulation independent from a page, it should be located in the Model (most of the time in askeet/lib/model/). If it concerns the final presentation, it should be located in the View; in symfony, the view layer relies on templates (for instance in askeet/apps/frontend/modules/question/templates/) and configuration files. We can read more about this model in the: http://www.symfony-project.org/book/1_0/02-Exploring-Symfony-s-Code
Đã gửi cách đây 5463 ngàyc. Test Data access via a CRUD In the askeet/ directory, type: $ symfony propel-generate-crud frontend question Question The list of all the actions created by a CRUD generator is: Action name Description list shows all the records of a table index forwards to list show shows all the fields of a given record edit displays a form to create a new record or edit an existing one update modifies a record according to the parameters given in the request, then forwards to show delete deletes a given record from the table Note: - Can find more a bout generated - Whenever you add a new class that need to be autoloaded, don't forget to clear the config cache (to reload the autoloading cache): $ symfony cc frontend config
Đã gửi cách đây 5463 ngàyb. Object Model build To use the InnoDB engine, one line has to be added to the propel.ini file of the askeet/config/ directory: propel.mysql.tableType = InnoDB Once the schema.xml is built, you can generate an object model based on the relational model. In symfony, the object relational mapping is handled by Propel, but encapsulated into the symfony command: $ symfony propel-build-model 2. Database a. Connection Now that symfony has an object model of the database, it is time to connect your project to the MySQL database. First, you have to create a database in MySQL: $ mysqladmin -u youruser -p create askeet Open the configuration file (askeet/config/databases.yml) we are ready to edit the file and enter the actual connection settings to your database under the all: category: all:
propel: class: sfPropelDatabase param: phptype: mysql host: localhost database: askeet username: youruser password: yourpasswd
Note: We can know more about symfony configuration and YAML files in the: http://www.symfony-project.org/book/1_0/19-Mastering-Symfony-s-Configuration-Files b. Build If we didn't write the schema.xml file by hand, we probably already have the corresponding tables in our database. We can then skip this part. For we keyboard fans, here is a surprise: We don't need to create the tables and the columns in the MySQL database. We did it once in the schema.xml, so symfony will build the SQL statement creating: $ symfony propel-build-sql This command creates a lib.model.schema.sql in the askeet/data/sql/ directory. Use it as a SQL command in MySQL: $ mysql -u youruser -p askeet < data/sql/lib.model.schema.sql Use the propel-insert-sql task: $ symfony propel-insert-sql
Đã gửi cách đây 5463 ngàyThere are two ways to write this file: by hand, and that's the way we like it, or from an existing database. - First, we need to remove the sample YAML file installed by default: $ svn delete config/schema.yml The syntax of the schema.xml, explained in detail on the: http://propel.phpdb.org/trac/
schema.xml is an XML file, in whichtags contain <column>, <foreign-key> and <index> tags. Once you write one, we can write all of them. - There is another way to create a schema.xml if we have an existing database. That is, if we are familiar with a graphical database design tool, we will prefer to build the schema from the generated MySQL database. Before we do that, we just need to edit the propel.ini file located in the askeet/config/ directory and enter the connection settings to your database: propel.database.url = mysql://username:password@localhost/databasename ...where username, password, localhost and databasename are the actual connection settings of your database. We can now call the propel-build-schema command (from the askeet/ directory) to generate the schema.xml from the database: $ symfony propel-build-schema Note: some tools allow you to build a database graphically and generate directly a schema.xml - Fabforce’s Dbdesigner : http://www.fabforce.net/dbdesigner4/ - DB Designer 4 To Propel Schema Converter: http://blog.tooleshed.com/docs/dbd2propel/transform.php Instead of creating a schema.xml file, we can also create a schema.yml file using the YAML schema format:
Đã gửi cách đây 5463 ngàyChappter 02 : Setting up Data Model 1. Data Model a. Relation Model: The purpose of the relational model is to provide a declarative method for specifying data and queries: we directly state what information the database contains and what information we want from it, and let the database management system software take care of describing data structures for storing the data and retrieval procedures for getting queries answered.It's easier to understand with an entity relationship diagram. The relational model has to be translated to a configuration file for symfony to understand it. That's the purpose of the schema.xml or schema.yml file, located in the askeet/config/ directory. Symfony supports schemas in the XML or YAML format.
Đã gửi cách đây 5463 ngày7. Subversion Source version control allows: - work fast - revert to a previous version if a modification is inefficient - allow more than one person to work on the project - have access to all the daily versions of the application First, create a new repository for the askeet project: $ svnadmin create $SVNREP_DIR/askeet $ svn mkdir -m "layout creation" file:///$SVNREP_DIR/askeet/trunk file:///$SVNREP_DIR/askeet/tags file:///$SVNREP_DIR/askeet/branches Next, you have to do the first import, omitting the cache/ and log/ temporary files: $ cd /home/sfprojects/askeet $ rm -rf cache/* $ rm -rf log/* $ svn import -m "initial import" . file:///$SVNREP_DIR/askeet/trunk Backup the original application directory and use a checkout of the SVN version $ cd /home/sfprojects $ mv askeet askeet.origin $ svn co file:///$SVNREP_DIR/askeet/trunk/ askeet/ $ ls askeet Delete the original directory we used for import $ rm -rf askeet.origin Specify an ignore list to SVN for this project. $ cd /home/sfprojects/askeet $ svn propedit svn:ignore cache
Đã gửi cách đây 5463 ngày6. Config IIS First, PHP5 installed and configured in IIS as an isapi module. a. Install Symfony First, update the pear package, since you need the version 1.4.0 to handle channels: $ pear upgrade PEAR Then, add the symfony channel: $ pear channel-discover pear.symfony-project.com Install symfony beta version >= 0.5.73: $ pear install symfony/symfony-beta Note: if you don't have the phing package, you will need to install it as well: $ pear install http://phing.info/pear/phing-current.tgz b. Initialize the project To create the directory of project: (C:\myproject), and the basic tree structure for an application called myapp $ cd c:\myproject $ symfony init-project myproject $ symfony init-app myapp c. Configure IIS In IIS administration console: Create the directory myapp is c:\myproject\, configure the root directory of your server to be c:\myproject\web d. Configuration of URL Rewriting Configure file httpd.ini
- Defend your computer from some worm attacks
RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
- we skip all files with .something except .html
RewriteCond URL .*\.. $ RewriteCond URL (?!.*\.html$).* RewriteRule (.*) $1 [L]
- we keep the .php files unchanged
RewriteRule (.*\.php)(.*) $1$2 [L]
- finally we redirect to our front web controller
RewriteRule (.*) /index.php [L] Note: We must restart IIS e. Configuring Symfony The last step is editing the file settings.yml located in the config directory of our symfony project (c:\myproject\apps\myapp\config\ all: .settings: path_info_key: HTTP_X_REWRITE_URL f. Configuring a symfony application in own directoty. - Create a subdirectory myapp in the web directory symfony project
(C:\myproject\web\myapp).
- Copy the files index.php and myapp_dev.php in this directory, create there two directories named css and uploads - In IIS administration console, create a new virtual directory on the root of your server named myapp. Configure this virtual directory to: C:\myproject\web\myapp. - Add these lines at the end of your httpd.ini file:
- [Configuration for direct myapp access]
# we skip all files with .something except .html RewriteCond URL /myapp/.*\.. $ RewriteCond URL (?!/myapp/.*\.html$).* RewriteRule /myapp/(.*) /myapp/$1 [L] # we keep the .php files unchanged RewriteRule /myapp/(.*\.php)(.*) /myapp/$1$2 [L] # finally we redirect to our front web controller RewriteRule /myapp/(.*) /myapp/index.php [L]
- Edit the file settings.yml of myapp application C:\myproject\apps\myapp\config\settings.yml all:
.settings: path_info_key: HTTP_X_REWRITE_URL
- Finally, edit both front controllers (index.php and myapp_dev.php in c:\myproject\web\myapp) and change: define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); To define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/../..'));
Đã gửi cách đây 5463 ngàyb. Declare the domain name The domain name askeet has to be declared locally. In Linux system, it has to be done in the /etc/hosts file. In Windows XP, this file is located in the: C:\WINDOWS\system32\drivers\etc\ directory. Add in the following line: 127.0.0.1 askeet Note: - We need to have administrator rights to do this. - If we don’t want to setup a new host, we add a Listen statement to serve website on other port. We can use localhost domain c. Test the new Configuration Restart Apache, and check the new application: http://askeet/ Symfony can use the mod_rewrite module to remove the /index.php/ part of the URLs. version of Apache is not compiled with mod_rewrite, check that you have the mod_rewrite DSO installed and the following lines in your httpd.conf: AddModule mod_rewrite.c LoadModule rewrite_module modules/mod_rewrite.so We can access the application in the development environment. http://askeet/frontend_dev.php/ Note: If the application works in the development environment (http://askeet/frontend_dev.php/), but not the production environment (http://askeet/) then check that mod_rewrite is configured in http.conf as described above, and restart Apache. It may also be necessary to run symfony cc at the command line to clear the symfony cache.
Đã gửi cách đây 5463 ngày5. Web service setup a. Web server configuration Now, we are using Apache Web server, we can change Apache configuration to make the new application accessible. In a professional context, it is better to setup a new application as a virtual host, and that's what will be described here. Note: We can add it as alias find how in the: http://www.symfony-project.org/cookbook/1_0/en/web_server Open the httpd.conf file of your Apache/conf/ directory and add at the end: NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName askeet DocumentRoot "/home/sfprojects/askeet/web" DirectoryIndex index.php Alias /sf /usr/local/lib/php/data/symfony/web/sf <Directory "/home/sfprojects/askeet/web"> AllowOverride All </Directory>
</VirtualHost> Note: The /sf alias has to point to the symfony folder in your PEAR data directory. To determine it, just type pear config-show. Symfony applications need to have access to this folder to get some image and javascript files, to properly run the web debug toolbar and the AJAX helpers. In Windows, We need to replace the Alias like with some thing like: Alias /sf "C:\php\pear\data\symfony\web\sf" If the above doesn't work, it may be necessary to specify permissions for the aliased /sf directory. The following from a working Windows WAMP installation. We can find it in the: http://www.wampserver.com/en/ NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80>
ServerName askeet DocumentRoot "C:/sfprojects/askeet/web" DirectoryIndex index.php Alias /sf "C:/wamp/php/PEAR/data/symfony/web/sf" <Directory "C:/sfprojects/askeet/web"> AllowOverride All Allow from All </Directory> <Directory "C:/wamp/php/PEAR/data/symfony/web/sf"> AllowOverride All Allow from All </Directory>
</VirtualHost> b.
Đã gửi cách đây 5463 ngày3. Install Symfony The simplest way to install symfony is to use the PEAR package So What is PEAR ?? PEAR - PHP Extension and Application Repository: Is a framework and distribution system for reusable PHP components. You can learn more about PEAR in: http://pear.php.net/ Note : to be able to use channels - and access the symfony channel - you need to upgrade to PEAR 1.4.0 or greater (unless you run PHP 5.1.0, which includes PEAR 1.4.5): - Upgrade Pear $pear upgrade PEAR - Add the “symfony” channel $ pear channel-discover pear.symfony-project.com - Install the latest stable version of symfony together with all its dependencies: $ pear install symfony/symfony - If a specific version is desired, say 1.0.11, it can be specified as follows: $ pear upgrade symfony/symfony-1.0.11 - Check that symfony is installed by using the command line to check the version (note capital -V): $ symfony -V We can see how to install symfony from a tgz archive or the svn repository in: http://www.symfony-project.org/book/1_0/03-Running-Symfony 4. Project Setup In symfony, applications sharing the same data model are regrouped into projects. We can already disclose the fact that there will be a frontend and a backend: that makes two applications. The project being the shell of the applications, it has to be created first. To do that, we need is a directory and a symfony init-project command line: $ mkdir /home/sfprojects/askeet $ cd /home/sfprojects/askeet $ symfony init-project askeet To create the frontend application with the symfony init-app command: $ symfony init-app frontend Note: Windows users are advised to run symfony and to setup their new project in a path which contains no spaces. Avoid using the Documents and Settings directory, including anywhere under My Documents (or Documents on Vista).
Đã gửi cách đây 5463 ngàyChappter 01: Starting up a Project. 1. The Project 2. This chappter content Display a page of the application in a web browser, and to setup a professional development environment. - Install Symfony - Create application - Config Web server - Setup source control system Symfony work well in Unix-like system with Apache, MySQL and PHP 5 installed. If we run Symfony in Windows system, we can type command in the Cmd prompt. Note: Unix shell commands can come in handy in a Windows environment. If use tools like tar, gzip, or grep in Windows you can install Cygwin (http://cygwin.com/). So What is Cygwin ? Cygwin is a Linux-like environment for Windows. It consists of two parts: - A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality. - A collection of tools which provide Linux look and feel. If install Cygwin, can be found installation guide in: http://users.soe.ucsc.edu/~you/notes/cygwin-install.html The adventurous may also like to try Microsoft's Windows Services for Unix: http://technet.microsoft.com/en-gb/interopmigration/bb380242.aspx
Đã gửi cách đây 5463 ngàyĐã gửi cách đây 5468 ngàyĐã gửi cách đây 5468 ngàyĐã gửi cách đây 5468 ngày@Takosan: tình yêu nghĩ thêm cái j hộ e nữa nhé. Chuyện này quan trọng với bạn e lắm, bạn gái lâu ngày k gặp(người quan trọng trong đời người ta ^^)
Đã gửi cách đây 5481 ngàyhi anh takoyaki, em là vietlem tên tháºt là Việt(hiii). Số Ä‘iện thoại của em là 08035836915 yhm: vietlembk@yahoo.com. Rất vui được biết anh.
Đã gửi cách đây 5486 ngàyChà o Tako! ^^.Mình má»›i há»c tiếng Nháºt, có gì mong bạn chỉ giáo. À, bạn thÃch món má»±c nÆ°á»›ng của dân Osaka hả?
Đã gửi cách đây 5494 ngàyu can add YM ID baambootratu or facebook fanpage http://www.facebook.com/baambootratu for more details :)
tác giả
Tìm thêm với Google.com :
NHÀ TÀI TRỢ