Modular Zend Framework app & Doctrine integration and usage - php

I need help, cause I am little stuck on this.
I have set up a modular Zend Framework app. Also using -- https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD- -- i integrated Doctrine 2.
My directory structure is like this:
-aplication/
--default/ --module1
---config
---controllers/
---forms/
---models/
---templates/
---test/
--maintenance --module2
---config
---controllers/
---forms/
---models/
---templates/
---test/
-config
--Bootstrap.php
--aplication.ini
-library/
--Zend/
--Doctrine/
--doctrine.php
--cli-config.php
-sites/
--site1/
---index.php
I have my databse created. I will use some tools to generate YAML files from database.
The next step I want is to generate model classes from these YAML files.
I spend days searching, but I just coudn't find solution to generate classes to models folder of each module. OK, so I would solve the problem by generating these classes in one directory and then move it to their 'original' destination (models folders).
I need help on how to generate these classes. I am developing in Windows, and that is where I want to generate this.
I suppose I have to open cms, point to location of doctrine.php (in library folder) and enter command php doctrine.php + some arguments. But when I do that i have:
[InvalidArgumentException]
There are no commands defined in the "" namespace.
What am I missing? What am I doing wrong?
I will also try to contact author of these files https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD- to ask for explanation.
Thanks in advance. I would really appreciate your help.
If you need I can write some of my code from Bootstrap and application.ini if you need.

Try to generate the class from YML file .It is possible to use MySQL workbench to sync the database tables and then use the MySQL workbench YML file generator plugin to generate the YML files . Hope it helps.

Related

registering Bundle to symfony kernel

Instead of Using composer I download zip file of a bundle and extract this bundle to my symfony project. I change all relative address for example I change all namespace Trsteel\CkeditorBundle; to namespace Acme\TrsteelCkeditorBundle; for doing this I searched the downloaded directory for every Trsteel\CkeditorBundle and change all of them to Acme\TrsteelCkeditorBundle now when I want to use this Bundle on my project I register this bundle to my appKernel.php of symfony project But I reached this error
Error: Class 'Acme\TrsteelCkeditorBundle\TrsteelCkeditorBundle' not found in /Users/kingkong/Documents/workspace/dev/Project/SRC/app/AppKernel.php line 45
File names should be the same as namespace structure, capitalization may be an issue, so check that.
You may want to place the bundle in this way - "Acme\Trsteel\CkeditorBundle\CkeditorBundle"
Check whether you have actually changed the folder structure from Trsteel\CkeditorBundle to Acme\TrsteelCkeditorBundle. And also check your routing files as well. (I assume you have done the routing part as the error won't say that it can't get to that location.)
Cheers!

Laravel: How to include file from Vendor folder in Laravel

I am trying to include the YouTube Analytics Service of Google but I can not access it through the Vendor folder.
include(app_path.'path/to/analytics/Google_YoutubeAnalyticsService.php')
It is not working, because it defaults to the App folder.
How can I get out of the App folder and into the Vendor folder (where the YouTube Analytics file is at)?
The error is {
include(C:\xampp\htdocs\mysite\app/path/to/analytics/Google_YoutubeAnalyticsService.php):
failed to open stream: No such file or directory
From where do you want to include that file ?
Place a reference to your file in composer.json autoload object:
"autoload": {
"files":["your_file_path"]
}
Run composer dumpautoload, and you'll have your file :)
Actually you have in the helpers function the path so basically the function base_path give the direction to the root of your project so
echo base_path() . '/vendor';
Should be the route to your vendor folder.
You can se all the documentation in
Helper Functions Laravel
Be sure that you are seeing the documentation of the laravel version that you are using (I put the link for the 4.2 version).
This question was asked a long time ago and the answers reflect that. Most the time now all you need to do is import it using the "use" statement if you installed it with composer. Composer will already reference all the important directories.
It should be something like this, but it will vary depending on the project.
use FolderNameUsuallyGitHubUserName\ClassNameorGitHubProjectName\Class;
That could include a base class as well as some exception classes.
use FolderNameUsuallyGitHubUserName\ClassNameorGitHubProjectName\ClassException;
Usually most packages if compliant with modern composer and php standards work in this fashion.

Using pre existing library in Symfony

I am new to Symfony. I am trying to use a pre existing library that I have used for my Payment Gateway API, with Symfony (v2.3).
Before using Symfony I would have a composer.json file in the root directory and I would simply use PHP require 'vendor/Braintree.... However with Symfony I am having a really difficult time using the library for payment gateway API by importing it to my Controller.
Note: I am using an Entity in the same controller as follows, which has a similar directory structure and works great:
use Jets\JetsBundle\Entity\Company;
This is what I tried to use the payment gateway API:
use Jets\JetsBundle\Braintree\braintree\braintree_php\lib\Braintree;
and the Braintree.php contains:
namespace Widb\WidbBundle\Braintree\braintree\braintree_php\lib;
I keep getting the following error:
FatalErrorException: Error: Class 'Jets\JetsBundle\Controller\Braintree_Configuration' not found in C:\xampp\htdocs\www\symfony\src\Jets\JetsBundle\Controller\DefaultController.php line 239
And the DefaultController.php Line 239 contains:
Braintree_Configuration::environment('sandbox');
As a side note, I didn't do anything other than drag / drop the ready configured library directory from my old server to the Symfony directory on the new server. Am I missing some configuration script or cmd set up or something?
I appreciate any assistance in this regard. I will forever be grateful is someone can help me troubleshoot this.
Here is my DefaultController.php code:
http://pastebin.com/kwisEBzL
Many thanks in advance!
This Braintree project seems to be PSR-0, so you should be able to use it pretty easily.
Don't do this:
use Jets\JetsBundle\Braintree\braintree\braintree_php\lib\Braintree;
There is no such namespace.
Include the Braintree project using Composer (notice they have the PSR-0 autoloading config already: https://github.com/braintree/braintree_php/blob/master/composer.json).
EDIT: add this to your composer.json and don't forget to run composer update (or php composer.phar update)
Update 2: As pointed out in the comments, it is a good idea to use a stable tag/branch. That way, if there are breaking changes, you can make sure to fix them before updating. So always check the version of the library (2.23 may not be the latest version any more).
"require": {
...
"braintree/braintree_php": "~2.23"
},
The autoloader should pickup all of the classes if you use the global namespace (notice the leading slash):
\Braintree_Configuration::environment('sandbox');
Let me know if this works.
Side note, you should probably create a bundle that does the configuration for you in a centralized place.
You really missed out one of the first comments.. which was spot on and will most likely take away alot of headaches.
Follow the instructions given at https://github.com/cometcult/CometCultBraintreeBundle, this is a bundle that provides "Braintree". A bundle in this case actually is a "module" you can hook in, and configure by configuration files.
Relevant commands that are missing for handling composer:
http://getcomposer.org/doc/03-cli.md#install
http://getcomposer.org/doc/03-cli.md#require
As soon as you have finished it up you should take a look at the bottom two parts, besides conifgurating everything.
$factory = $this->get('comet_cult_braintree.factory');
$customerService = $factory->get('customer');
If you need more help let me know
I'm don't uderstand what you actually try to do in your DefaultController.php, but I have some assumptions.
UPD:
FIRST and SECOND point was deleted.
THIRD:
When you trying to make use Jets\JetsBundle\Braintree\braintree\braintree_php\lib\Braintree; you have load only class Braintree from file Braintree.php. Not whole file with another data like require_once instructions.
FOURTH:
/vendor directory of Symfony2 projects usually contains third-part libs. So you can put your lib here.
Hope some of this points helps you.
P.S. Sorry for poor English.

CodeIgniter 2.1 and SimpleTest - Conducting a simple test

I am currently using CI 2.1 and Netbeans 7.0 as my inveiglement IDE. I would like to create some simple unit testing using SimpleTest. In particular the methodology used by Eric Barnes and his code found at Git Hub CodeIgniter-SimpleTest. (https://github.com/ericbarnes/codeigniter-simpletest)
I have created a new CI application using Netbeans 7.0 and connected to my database (which contains 1 table called schools with the typical schema schoolid, schoolname, schooladdress etc.). I have created a controller (simpleapp), which loads a model called schools_model. The schools_model gets all the schools using a method called getAll(). Another method called getSchoolName(id), accepts a school ID and returns the school name.
The controller then loads a view called schools_view to display all the schools. Pretty simple stuff…....... and it works flawlessly, displaying all the schools when I point my browser to
http://localhost/SimpleTest/simpleapp/getAllSchools
(I am also using a .htaccess file, hence no index.php)
My question is this….......
How do I get SimpleTest to work using the Git hub code supplied by Eric?
I have followed Eric’s set-up advise, but don’t know what URL to point to to create the screen dumps he provides. I have maintained the directory structure Eric suggests but haven’t had any success. Eric suggest to point the browser to yoursite.com/unit_test.php, but I get a
404 page not found error for localhost/SimpleTest/unit_test.php
I assume the above error is due to the fact, like most CI applications, we need to use a controller first.
I would appreciate any direction in this area.
I have done exactly what you suggested. I have placed the unit_test.php file in the root directory and set up the test directory structure as suggested. However, when I point to localhost/SimpleTest/unit_test.php I get the 404 error.
My directory structure looks like
Source Files
-application (folder)
-system(folder)
-tests(folder from git hub with model/test_schools_model.php)
-.htaccess
-index.php
-licence.txt
-unit_test.php
Is it a .htaccess issue the reason I cannot view localhost/SimpleTest/unit_test.php?
You are correct you need to go to yoursite.com/unit_test.php or in your case localhost/SimpleTest/unit_test.php
You need to copy the unit_test.php file from github into the sites root directory and place the tests directory there too. You then put your tests in the appropriate folder under tests/

how to get started with doctrine

where can i find help getting started with doctrine? forums etc?
I'm trying to follow this;
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/getting-started/pl
but it refers to a Doctrine.php file that's located in the lib folder. There is no lib folder in the doctrine download. There is a bin folder with a doctrine file in itIs that what they are refering to?
What should the folder structure look like for a doctrine project? Currently i have this;
application
library
|
|-----Doctrine
|
|------common
|------DBAL
|------ORM
Where should the Doctine.php file go?
Doctrine uses PEARlike naming conventions, so Doctrine.php goes into the root of your include_path, or to the root of your library, next to the Doctrine directory. However, newer versions of Doctrine1 only keep this file for backwards compatibility. You should rather use 'Doctrine_Core' it 's the same class, but with a new name (and location).

Categories