Category Archives: symfony

  • -

Symfony Basic Interview Questions

Category : symfony

Symfony Basic Interview Questions

Symfony Basic Interview Questions

 

 

 

 

 

 

 

 

 

 

1).The end product of a controller in Symfony is always the same – what is it?

a).a Symfony2 Response object
b).a Symfony2 Presentation object
c).a Symfony2 Request object
d).a Symfony2 HTML object

Answer:a Symfony2 Response object

2).The controller in Symfony creates a new Response object, whose first argument is the

a).content that should be used in the request
b).content that should be used in the response
c).a PHP file that should be used in the request
d).3 arguments that should be used in the response

Answer:content that should be used in the response

3).In order to use the render() method in Symfony, your controller must extend the

a).Router Class b).Config Class c).Render Class d).Controller class

Answer:Controller class

4).A _____ defines the URL (e.g. /about) to your page and specifies a controller (which is a PHP function) that Symfony2 should execute
when the URL of an incoming request matches the route path.
a).path b).home path c).route d).controller path

Answer:route

5).A controller in Symfony is a
a).a YAML function b).a PHP function c).a XML Config file d).None

Answer:a PHP function

6). Which of the following returns Symfony2 Response object back to the user?
a).Bundle b).Kernel c).Controller d).Model

Answer:Controller

7).Which of the following in Symfony is a directory that houses everything related to a specific feature, including PHP classes, configuration, and
even stylesheets and Javascript files?.
a).Bundle b).Router c).Controller d).Model

Answer:Bundle

8).In Symfony, to create a bundle called AcmeHelloBundle, which of the following command need to be run?
a).$ php app/console generate:bundle –namespace=Acme –format=yml
b).$ php app/console generate:bundle –namespace=”/HelloBundle –format=yml
c).$ php app/console generate:bundle –namespace=AcmeHelloBundle/HelloBundle –format=yml
d).$ php app/console generate:bundle –namespace=Acme/HelloBundle –format=yml

Answer:$ php app/console generate:bundle –namespace=Acme/HelloBundle –format=yml

9).The Request class symfony is a simple object-oriented representation of the
a).HTTP request message b).HTML request message c).PHP request message d).TCP request message

Answer:HTTP request message

10).In symfony, the code where you interpret the request and create a response is the
a).Request b).Controller c).Router d).Interpreter

Answer:Controller

11).In Symfony, the routing configuration can be written in

a).YAML b).PHP c).XML d).All of the above

Answer:.All of the above

12).Symfony2 packages called ____________, which are fully functional applications that include the Symfony2 core libraries, a selection of useful bundles,
a sensible directory structure and some default configuration.
a).distributions b).binaries c).core libs d).composer

Answer:distributions

13).By default, the routing configuration file in a Symfony2 application is located at
a).app/config/routing.yml
b).app/yaml/routing.yml
c).app/config_route/routing.yml
d).app/config/routing.config

Answer:app/config/routing.yml

14).In Symfony, The routing consists of two basic pieces: the _____, which is the URL that this route will match, and
a defaults array, which specifies the ________ that should be executed.
a).path,controller
b).route,controller
c).path,router
d).router,controller

Answer:path,controller

15).The goal of each controller in Symfony is to return a
a).Response object b).Request Object c).PHP Object d).None

Answer: Response


  • -

Online twig template engine pdf file

Category : symfony

Online twig template engine pdf file

Online twig template pdf file
 

 

 
 

 

 
 

 

 

Twig is a modern template engine for PHP

 

Fast: Twig compiles templates down to plain optimized PHP code. The overhead compared to regular PHP code was reduced to the very minimum.                                                                                                                                                                                                                                                           

  • Secure: Twig has a sandbox mode to evaluate untrusted template code. This allows Twig to be used as a template language for applications where users may modify the template design.
  • Flexible: Twig is powered by a flexible lexer and parser. This allows the developer to define its own custom tags and filters, and create its own DSL.

Why yet another template engine?

When it comes to template engines in PHP, many people will tell you that PHP itself is a template engine. But even if PHP started its life as a template language, it did not evolve like one in the recent years. As a matter of fact, it doesn’t support many features modern template engines should have nowadays:

  • Concise: The PHP language is verbose and becomes ridiculously verbose when it comes to output escaping:
    <?php echo $var ?>
    <?php echo htmlspecialchars($var, ENT_QUOTES, 'UTF-8') ?>
    

    In comparison, Twig has a very concise syntax, which make templates more readable:

    {{ var }}
    {{ var|escape }}
    {{ var|e }}         {# shortcut to escape a variable #}
    
  • Template oriented syntax: Twig has shortcuts for common patterns, like having a default text displayed when you iterate over an empty array:
    {% for user in users %}
        * {{ user.name }}
    {% else %}
        No users have been found.
    {% endfor %}
    
  • Full Featured: Twig supports everything you need to build powerful templates with ease: multiple inheritance, blocks, automatic output-escaping, and much more:
    {% extends "layout.html" %}
    
    {% block content %}
        Content of the page...
    {% endblock %}
    
  • Easy to learn: The syntax is easy to learn and has been optimized to allow web designers to get their job done fast without getting in their way.

Of course, PHP is also the language for which you can find the more template engine projects. But most of them are still developed with PHP4 in mind, and do not embrace web development best practices:

  • Extensibility: Twig is flexible enough for all your needs, even the most complex ones. Thanks to an open architecture, you can implement your own language constructs (tags, filters, functions, and even operators) to create your very own DSL.
  • Unit tested: Twig is fully unit-tested. The library is stable and ready to be used in large projects.
  • Documented: Twig is fully documented, with a dedicated online book, and of course a full API documentation.
  • Secure: When it comes to security, Twig has some unique features:
    • Automatic output escaping: To be on the safe side, you can enable automatic output escaping globally or for a block of code:
      {% autoescape true %}
          {{ var }}
          {{ var|raw }}     {# var won't be escaped #}
          {{ var|escape }}  {# var won't be doubled-escaped #}
      {% endautoescape %}
      
    • Sandboxing: Twig can evaluate any template in a sandbox environment where the user has access to a limited set of tags, filters, and object methods defined by the developer. Sandboxing can be enabled globally or locally for just some templates:
      {{ include('page.html', sandboxed = true) }}
      
  • Clean Error Messages: Whenever you have a syntax problem within a template, Twig outputs a helpful message with the filename and the line number where the problem occurred. It eases the debugging a lot.
  • Fast: One of the goals of Twig is to be as fast as possible. To achieve the best speed possible, Twig compiles templates down to plain optimized PHP code. The overhead compared to regular PHP code was reduced to the very minimum.
Read twig book online
 

Source


  • 0

what are benefits of using doctrine orm

Category : programming , symfony

What are benefits of using doctrine orm

what are benefits of using doctrine orm

Why use doctrine

 

  • Around since 2006 with very stable, high-quality codebase.
  • Extremely flexible and powerful object-mapping and query features.
  • Support for both high-level and low-level database programming for all your use-cases.
  • Large Community and integrations with many different frameworks (Symfony, Zend Framework, CodeIgniter, FLOW3, Lithium and more)

General definition of doctrine

 

The Doctrine Project is the home to several PHP libraries primarily focused on database storage and object mapping. The core projects are aObject Relational Mapper (ORM) and the Database Abstraction Layer (DBAL) it is built upon. Doctrine has greatly benefited from concepts of the Hibernate ORM and has adapted them to fit the PHP language.

Database Abstraction Layer

Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.

Object Relational Mapper

Object relational mapper (ORM) for PHP that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.

Says Doctrine

What is Object/Relational Mapping?

If you are already familiar with Java, with Object/Relational Mapping, and with the Object/Relational mismatch, you may want to skip right to the Hibernate ORM benefits

Persistence in ORM

Hibernate ORM is concerned with helping your application to achieve persistence. So what is persistence? Persistence simply means that we would like our application’s data to outlive the applications process. In Java terms, we would like the state of (some of) our objects to live beyond the scope of the JVM so that the same state is available later.

Relational Databases in ORM

Specifically, Hibernate ORM is concerned with data persistence as it applies to relational databases (RDBMS). In the world of Object-Oriented applications, there is often a discussion about using anobject database (ODBMS) as opposed to a RDBMS. We are not going to explore that discussion here. Suffice it to say that RDBMS remain a very popular persistence mechanism and will so for the foreseeable future.

The Object-Relational Impedance Mismatch  in ORM

‘Object-Relational Impedance Mismatch’ (sometimes called the ‘paradigm mismatch’) is just a fancy way of saying that object models and relational models do not work very well together. RDBMSs represent data in a tabular format (a spreadsheet is a good visualization for those not familiar with RDBMSs), whereas object-oriented languages, such as Java, represent it as an interconnected graph of objects. Loading and storing graphs of objects using a tabular relational database exposes us to 5 mismatch problems…​

Granularity in ORM

Sometimes you will have an object model which has more classes than the number of corresponding tables in the database (we says the object model is more granular than the relational model). Take for example the notion of an Address…​

Subtypes (inheritance) in ORM

Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not define anything similar on the whole (yes some databases do have subtype support but it is completely non-standardized)…​

Identity in ORM

A RDBMS defines exactly one notion of ‘sameness’: the primary key. Java, however, defines both object identity a==b and object equality a.equals(b).

Associations in ORM

Associations are represented as unidirectional references in Object Oriented languages whereas RDBMSs use the notion of foreign keys. If you need bidirectional relationships in Java, you must define the association twice.

Likewise, you cannot determine the multiplicity of a relationship by looking at the object domain model.

Data navigation in ORM

The way you access data in Java is fundamentally different than the way you do it in a relational database. In Java, you navigate from one association to an other walking the object network.

This is not an efficient way of retrieving data from a relational database. You typically want to minimize the number of SQL queries and thus load several entities via JOINs and select the targeted entities before you start walking the object network.

Source Hibernate

WHAT IS RELATIONAL ORM MAPPING


  • 0

what is object relational mapping

Category : programming , symfony

What is object relational mapping

Definition of orm in wikipedia

what is object relational mapping

 

 

 

 

 

 

 

 

 

 

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer science is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools.

says wikipedia

orm definition 

Object Role Modeling (ORM) is a powerful method for designing and querying database models at the conceptual level, where the application is described in terms easily understood by non-technical users. In practice, ORM data models often capture more business rules, and are easier to validate and evolve than data models in other approaches.

This site features a number of technical papers and articles on ORM, as well as other approaches such as the Unified Modeling Language (UML). Permission has been obtained from the relevant publishers to reproduce these publications on this website, and to make them freely downloadable. If you are unfamiliar with ORM, you may want to first review the ORM in Detail section of this site. Details about upcoming courses and conferences, as well as links to websites with additional ORM publications may be found in the Resources section.

says orm.net

doctrine power and orm

 

Object relational mapper (ORM) for PHP that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.

says dorctrine

 

Benefits of using orm


  • 0

symfony shell available commands

Category : symfony

Symfony shell available commands

symfony shell available commands

 

 

 

 

 

 

 

 

 

 

Procedure for getting symfony shell commands

Go to your cmd and type the following according to your machine

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Developer 1>cd c:\wamp\www

c:\wamp\www>cd greatsymfony

c:\wamp\www\greatsymfony>php app/console
Symfony version 2.3.30 – app/dev/debug

Usage:
command [options] [arguments]

Options:
–help -h Display this help message
–quiet -q Do not output any message
–verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
–version -V Display this application version
–ansi Force ANSI output
–no-ansi Disable ANSI output
–no-interaction -n Do not ask any interactive question
–shell -s Launch the shell.
–process-isolation Launch commands from shell as a separate process.
–env -e The Environment name.
–no-debug Switches off debug mode.

Available commands:
help Displays help for a command
list Lists commands
assetic
assetic:dump Dumps all assets to the filesystem
assetic:watch Dumps assets to the filesystem as their source files are modified
assets
assets:install Installs bundles web assets under a public web directory
cache
cache:clear Clears the cache
cache:warmup Warms up an empty cache
config
config:dump-reference Dumps default configuration for an extension
container
container:debug Displays current services for an application
debug
debug:swiftmailer Displays current mailers for an application
doctrine
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:database:create Creates the configured database
doctrine:database:drop Drops the configured database
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment.
doctrine:generate:crud Generates a CRUD based on a Doctrine entity
doctrine:generate:entities Generates entity classes and method stubs from your mapping information
doctrine:generate:entity Generates a new Doctrine entity inside a bundle
doctrine:generate:form Generates a form type class based on a Doctrine entity
doctrine:mapping:convert Convert mapping information between supported formats.
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info
doctrine:query:dql Executes arbitrary DQL directly from the command line.
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
doctrine:schema:validate Validate the mapping files.
generate
generate:bundle Generates a bundle
generate:controller Generates a controller
generate:doctrine:crud Generates a CRUD based on a Doctrine entity
generate:doctrine:entities Generates entity classes and method stubs from your mapping information
generate:doctrine:entity Generates a new Doctrine entity inside a bundle
generate:doctrine:form Generates a form type class based on a Doctrine entity
init
init:acl Mounts ACL tables in the database
orm
orm:convert:mapping Convert mapping information between supported formats.
router
router:debug Displays current routes for an application
router:dump-apache Dumps all routes as Apache rewrite rules
router:match Helps debug routes by simulating a path info match
server
server:run Runs PHP built-in web server
swiftmailer
swiftmailer:debug Displays current mailers for an application
swiftmailer:email:send Send simple email message
swiftmailer:spool:send Sends emails from the spool
translation
translation:update Updates the translation file
twig
twig:lint Lints a template and outputs encountered errors

c:\wamp\www\greatsymfony>


  • 0

symfony doctrine exception list

Category : symfony

symfony doctrine exception list

 

 

 

 

 

 

 

symfony doctrine exception list

symfony2 installations also include doctrine2, below is a list of all the Doctrine 2 Exceptions

Doctrine/Common/DataFixtures/Exception/CircularReferenceException.php
Doctrine/Common/Annotations/AnnotationException.php
Doctrine/Common/CommonException.php
Doctrine/Common/Persistence/Mapping/MappingException.php
Doctrine/ORM/TransactionRequiredException.php
Doctrine/ORM/Query/QueryException.php
Doctrine/ORM/Query/AST/ASTException.php
Doctrine/ORM/Mapping/MappingException.php
Doctrine/ORM/UnexpectedResultException.php
Doctrine/ORM/PessimisticLockException.php
Doctrine/ORM/OptimisticLockException.php
Doctrine/ORM/Internal/Hydration/HydrationException.php
Doctrine/ORM/ORMException.php
Doctrine/ORM/NonUniqueResultException.php
Doctrine/ORM/EntityNotFoundException.php
Doctrine/ORM/Tools/ToolsException.php
Doctrine/ORM/Tools/Export/ExportException.php
Doctrine/ORM/Proxy/ProxyException.php
Doctrine/ORM/NoResultException.php
Doctrine/ORM/ORMInvalidArgumentException.php
Doctrine/DBAL/Query/QueryException.php
Doctrine/DBAL/Types/ConversionException.php
Doctrine/DBAL/Schema/SchemaException.php
Doctrine/DBAL/Sharding/ShardingException.php
Doctrine/DBAL/ConnectionException.php
Doctrine/DBAL/Cache/CacheException.php
Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
Doctrine/DBAL/Driver/Mysqli/MysqliException.php
Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php
Doctrine/DBAL/DBALException.php


  • 0

symfony exception list

Category : symfony

symfony exception list

 

 

 

 

 

 

 

symfony exception list

Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php

Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php

Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php

Symfony/Component/Serializer/Exception/InvalidArgumentException.php

Symfony/Component/Serializer/Exception/UnsupportedException.php

Symfony/Component/Serializer/Exception/UnexpectedValueException.php

Symfony/Component/Serializer/Exception/LogicException.php

Symfony/Component/Serializer/Exception/Exception.php

Symfony/Component/Serializer/Exception/RuntimeException.php

Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php

Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php

Symfony/Component/HttpKernel/Exception/HttpException.php

Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php

Symfony/Component/HttpKernel/Exception/FlattenException.php

Symfony/Component/Form/Exception/InvalidConfigurationException.php

Symfony/Component/Form/Exception/TransformationFailedException.php

Symfony/Component/Form/Exception/PropertyAccessDeniedException.php

Symfony/Component/Form/Exception/TypeLoaderException.php

Symfony/Component/Form/Exception/NotInitializedException.php

Symfony/Component/Form/Exception/NotValidException.php

Symfony/Component/Form/Exception/AlreadyBoundException.php

Symfony/Component/Form/Exception/InvalidPropertyPathException.php

Symfony/Component/Form/Exception/CreationException.php

Symfony/Component/Form/Exception/StringCastException.php

Symfony/Component/Form/Exception/FormException.php

Symfony/Component/Form/Exception/TypeDefinitionException.php

Symfony/Component/Form/Exception/UnexpectedTypeException.php

Symfony/Component/Form/Exception/ErrorMappingException.php

Symfony/Component/Form/Exception/InvalidPropertyException.php

Symfony/Component/Process/Exception/ProcessFailedException.php

Symfony/Component/Process/Exception/RuntimeException.php

Symfony/Component/Yaml/Exception/DumpException.php

Symfony/Component/Yaml/Exception/ParseException.php

Symfony/Component/Filesystem/Exception/IOException.php

Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php

Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php

Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php

Symfony/Component/HttpFoundation/File/Exception/UploadException.php

Symfony/Component/HttpFoundation/File/Exception/FileException.php

Symfony/Component/DependencyInjection/Exception/InvalidArgumentException.php

Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php

Symfony/Component/DependencyInjection/Exception/LogicException.php

Symfony/Component/DependencyInjection/Exception/OutOfBoundsException.php

Symfony/Component/DependencyInjection/Exception/BadMethodCallException.php

Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php

Symfony/Component/DependencyInjection/Exception/RuntimeException.php

Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php

Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php

Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php

Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php

Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php

Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php

Symfony/Component/Config/Exception/FileLoaderLoadException.php

Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php

Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php

Symfony/Component/Config/Definition/Exception/UnsetKeyException.php

Symfony/Component/Config/Definition/Exception/Exception.php

Symfony/Component/Config/Definition/Exception/InvalidDefinitionException.php

Symfony/Component/Config/Definition/Exception/InvalidTypeException.php

Symfony/Component/Config/Definition/Exception/DuplicateKeyException.php

Symfony/Component/Routing/Exception/InvalidParameterException.php

Symfony/Component/Routing/Exception/ResourceNotFoundException.php

Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php

Symfony/Component/Routing/Exception/RouteNotFoundException.php

Symfony/Component/Routing/Exception/MethodNotAllowedException.php

Symfony/Component/Validator/Exception/MappingException.php

Symfony/Component/Validator/Exception/MissingOptionsException.php

Symfony/Component/Validator/Exception/GroupDefinitionException.php

Symfony/Component/Validator/Exception/ConstraintDefinitionException.php

Symfony/Component/Validator/Exception/UnexpectedTypeException.php

Symfony/Component/Validator/Exception/InvalidOptionsException.php

Symfony/Component/Validator/Exception/ValidatorException.php

Symfony/Component/Locale/Exception/MethodArgumentValueNotImplementedException.php

Symfony/Component/Locale/Exception/MethodArgumentNotImplementedException.php

Symfony/Component/Locale/Exception/MethodNotImplementedException.php

Symfony/Component/Locale/Exception/NotImplementedException.php

Symfony/Component/CssSelector/Exception/ParseException.php

Symfony/Component/Security/Core/Exception/SessionUnavailableException.php

Symfony/Component/Security/Core/Exception/AuthenticationException.php

Symfony/Component/Security/Core/Exception/UnsupportedUserException.php

Symfony/Component/Security/Core/Exception/AccessDeniedException.php

Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php

Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php

Symfony/Component/Security/Core/Exception/LogoutException.php

Symfony/Component/Security/Core/Exception/CookieTheftException.php

Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php

Symfony/Component/Security/Core/Exception/DisabledException.php

Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php

Symfony/Component/Security/Core/Exception/LockedException.php

Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php

Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php

Symfony/Component/Security/Core/Exception/TokenNotFoundException.php

Symfony/Component/Security/Core/Exception/AccountExpiredException.php

Symfony/Component/Security/Core/Exception/NonceExpiredException.php

Symfony/Component/Security/Core/Exception/AccountStatusException.php

Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php

Symfony/Component/Security/Core/Exception/BadCredentialsException.php

Symfony/Component/Security/Acl/Exception/SidNotLoadedException.php

Symfony/Component/Security/Acl/Exception/AclNotFoundException.php

Symfony/Component/Security/Acl/Exception/NotAllAclsFoundException.php

Symfony/Component/Security/Acl/Exception/InvalidDomainObjectException.php

Symfony/Component/Security/Acl/Exception/NoAceFoundException.php

Symfony/Component/Security/Acl/Exception/Exception.php

Symfony/Component/Security/Acl/Exception/ConcurrentModificationException.php

Symfony/Component/Security/Acl/Exception/AclAlreadyExistsException.php


  • 0

namespace in php

Category : php , symfony

what are namespaces in c sharp

 namespace in php

  1. it is used to control the scope of classes in larger projects
  2. it is used to organize classes
  3. It is used to avoid code duplication in classes when there are multile vendors code
  4. php provides us directive for shortening class which method is defined.
  5. namespace is big term defined and used when oop began to working.
  6. It is big vendor term where we can use different classes defined by different vendor names without any function

classes methods either they are same or not provided namespace keywod with relevative bundle container imported.
Namespace actually provides us the logic of wheel reinventing so it revolutioned our programming and led us to faster development.They make us avoid from collapsing against classes ,bundles, containter etc.

namespace in php

Namespaces are php program elements designed to help you organize your programs. when we write a class named Library, we would need to put it in our own namespace to ensure that there wasn’t any confusion about when Library class should be used or when your class should be used. Generally, it would be a bad idea to create a class named Library, but in many cases your classes will be named the same as classes in either the php namespace classesor a third party library and namespaces help you avoid the problems that identical class names would cause.

 

Namespaces don’t correspond to file or directory names. If naming directories and files to correspond to namespaces helps you organize your code, then you may do so, but it is not required.

The big example of packigst.org website where different vender bundles are defined and work without any class or function or method or interface collasping with each other.

Learn more about php and its function


  • 0

how to install 3rd party bundle in symfony

Category : symfony

How to install 3rd party bundle in symfony

 

 

 

 

 

 

 

How to install 3rd party bundle in symfony

Follow these easy steps to install 3rd party bundle

step no 1:

Add it to the “composer.json“ file:

 

{
…,
“require”: {
…,
“SwiftCodeBundle/My-bundle”: “2.0.*@dev”
}
}

step no 2 :

Update the dependency:
1 $ php composer.phar update SwiftCodeBundle/My-bundle
or update all dependencies
1 $ php composer.phar update

Or we can install it by this way

This can be done by command prompt :
1 $ php composer.phar require SwiftCodeBundle/My-bundle:2.0.*@dev

Step no 3:

/ app/AppKernel.php
// …
class AppKernel extends Kernel
{
// …
public function registerBundles()
{
$bundles = array(
// …,

new SwiftCodeBundle\My-bundle(),
);
// …
}
}

step no 4:

$ app/console config:dump-reference assetic

The output will look like this:
assetic:
debug: %kernel.debug%
use_controller:
enabled: %kernel.debug%
profiler: false
read_from: %kernel.root_dir%/../web
write_to: %assetic.read_from%
java: /usr/bin/java
node: /usr/local/bin/node
node_paths: []
# …

or

$ app/console config:dump-reference AsseticBundle

Now if anything is left , we can check it by reading md file.


  • 0

how to use assets filter to specific file in symfony

Category : symfony

how to use assets filter to specific file in symfony

 

 

 

 

 

 

 

How to use assets filter to specific file in symfony

We can use assets filter to multiple or one file, there are given below different examples to understand the theory of assetic filter in symfony.

Follow this simple procedure by first activate it
If we want to use coffee script the following setting would happen:
 
# app/config/config.yml
assetic:
filters:
coffee:
bin: /usr/bin/coffee
node: /usr/bin/node
node_paths: [ /usr/lib/node_modules/ ]

Now if we are using single filter the following settings would be followed by:

{% javascripts ‘@YourFooBundle/Resources/public/js/example.coffee’ filter=’coffee’ %}
<script src=”{{ asset_url }}” type=”text/javascript”></script>
{% endjavascripts %}

Happy coding to single filter

Now if we want to use multiple filters
{% javascripts ‘@YourFooBundle/Resources/public/js/one.coffee’
‘@YourFooBundle/Resources/public/js/second.coffee’
filter=’coffee’ %}
<script src=”{{ asset_url }}” type=”text/javascript”></script>
{% endjavascripts %}

Happy coding to filter for multiple files

One very fast and interesting thing which symfony also provides is an file base extention like :

Use this configuration :

# app/config/config.yml
assetic:
filters:
coffee:
bin: /usr/bin/coffee
node: /usr/bin/node
node_paths: [ /usr/lib/node_modules/ ]
apply_to: “\.coffee$”

That above would avoid us from referencing again and again same filter.

Now go to your coding and use the following syntax:

{% javascripts ”@YourFooBundle/Resources/public/js/my.js’
‘@YourFooBundle/Resources/public/js/second.coffee’
 @YourFooBundle/Resources/public/js/first.coffee’%}
<script src=”{{ asset_url }}” type=”text/javascript”></script>
{% endjavascripts %}



Fatal error: Call to undefined function weblizar_navigation() in /home/websolutionsdone/public_html/wp-content/themes/ielts-career/category.php on line 23