Put Business Logic In A Library?

i'm going to create a library that consists of a lot of separate classes.

i'm very familiar with mvc but have never created a pure library before.

i wonder where i should put the business logic? the kind of logic that usually resides in a controller in a mvc. should it be in a class or in a "bootstrap" file?

and should one file include every class, or should only one class include its classes it uses?

to clarify: my goal is not to create a mvc, but a pure library eg. email or guestbook that others can use.



ADVERTISEMENT

Separation Of Presentation And Business Logic

I am programming my first real PHP website and am wondering how to make my code more readable to myself. The reference book I am using is PHP and MySQL Web Development 4th ed. The aforementioned book gives three approaches to separating logic and content:

include files
function or class API
template system

I haven't chosen any of these yet, as wrapping my brains around these concepts is taking some time. However, my code has become some hybrid of the first two as I am just copy-pasting away here and modifying as I go. On presentation side, all of my pages have these common elements: header, top navigation, sidebar navigation, content, right sidebar and footer. The function-based examples in the book suggest that I could have these display functions that handle all the presentation example. So, my page code will be like this:

display_header();
display_navigation();
display_content();
display_footer();

However, I don't like this because the examples in the book have these print statements with HTML and PHP mixed up like this:

echo "<tr bgcolor="".$color.""><td><a href="".$url."">" ...

I would rather like to have HTML with some PHP in the middle, not the other way round. I am thinking of making my pages so that at the beginning of my page, I will fetch all the data from database and put it in arrays. I will also get the data for variables. If there are any errors in any of these processes, I will put them into error strings..............

View 4 Replies View Related

Business Logic Situated In MVC Pattern?

I use zend framework and doctrine. And in many project business logic build-ed in controller but this method is wrong as me. Best method what I saw it is using service layers where business logic is wrote. But all development reduced to create form, validate it and use some business logic in service layer. Result validation, business logic and work with mixed in one method for example newProduct($postData). My questions what is true way of organization business logic in MVC? maybe i need to read some books or see some examples of source code.

View 2 Replies View Related

Zend_Layout: Where To Write Business Logic?

On most project I use multiple layout scripts.Sometimes I need some data in my layouts that are layout-specific, instead of page-specific. Which layout gets used though, IS page-specific.So the bootstrap or actioncontroller would be good places to select a layout. But IMHO they would not be good places to inject the data a particular layout expects. The only other place I can think of is to just write some business logic in the layout viewscript itself. Though that's something I'd rather not do either :)Where do you write your layout-specific business logic?

View 1 Replies View Related

How Should Partials Be Loaded When They Are Dependent On Business Logic

I'm using the term "partial" to refer to a small section of presentational code which is repeated on many views. For example, a sidebar. In vanilla PHP, where the business and presentation logic is mixed, including a sidebar is no trouble:

if($someCondition) {
include('sidebar.php');
}

However, in an MVC design pattern, the presentational logic must be kept in the view whilst the business logic must be kept in the controller. If I wish to include a partial unconditionally, then this is unproblematic since I can just have include('sidebar.php') in my view. However, I can no longer do so conditionally because that if logic is banned from my view. I have attempted a number of solutions but they all have problems. I am currently using Solution 2:

Solution 1: Create an include function in my view class which could conditionally include content from my controller. So in my controller I could have the following logic:

if($someCondition) {
$this->view->include('sidebar.php');
}
$this->view->show('index.php');

Problems: sidebar.php will need to be included into index.php at a specific point requiring the include method on the view object to do some sort of parsing...........

View 2 Replies View Related

OOP: Business Logic Layer - DB Layer?

what could be a good design for layering between the business logic objects and the Database using OOP?

View 2 Replies View Related

Drupal Form Filter / Economics Student Choose For A Training Business Than Must All Titles Of Books Appear Only The Business?

I have created a basic Drupal form. Now i want, if for example a ingenieur student choose for a training industrial sciences than must al titles of books appear. But, if a economics student choose for a training business than must al titles of books appear only the business and not the titles of industrial sciences or others.I think a filter would fix my problem.

View 2 Replies View Related

Separate Bussiness Logic/ Presentation Logic Procedural ?

how to separate business and logic in a non-OOP way?I've been searching online, but almost all solutions are for OOP.

Is it possible to do something like MVC in procedural PHP?

View 8 Replies View Related

Mixing Presentational Logic With Model Logic Too Much?

So I am still somewhat new to PHP, MySQL, and Javascript but I have been working on a project so I have been learning fast. However, I feel like in my php pages I am mixing too much HTML and PHP. At first I thought it was standard practice but someone on SO informed me of how you should not mix the two and I began looking at my code.

For example, when loading a page of submissions I have a loop that looks something like this (condensed version):

<?php
while ($row = mysql_fetch_assoc($submissionQuery))
{
$submissionID = $row['id'];[code]...

The reason why I don't just enclose the entire block in PHP is because there is not only an h3 there and I don't want to use mass-echo statements.In my opinion this looks terrible and I'd like to know a better way of doing it. I suppose that I could store all the submissions in to an array and then loop through them later on but I see several downsides to this:

1) Unnecessarily storing values in to an array. Only going to recall them immediately after.

2) If there are a lot of submissions there may not be enough memory to store them.

3) Would require more code.

4) Would still have to loop through the array later on and in that case I am still mixing PHP and HTML (just to a lesser degree)

I don't know. I just need some advice as to best handle this because I don't want to do things the wrong way and then have to refactor everything later on when something breaks or gets too complex.

View 3 Replies View Related

Not Mix Presentation With Logic / Counts As Mixing Presentation With Logic?

I use PHP quite a bit, and whenever I see a "PHP-hate" thread on some forum or even popular PHP-related discussions here, I usually see something along the lines of:

PHP is too messy/sloppy/crappy, because you have a tangled web of presentation and logic.

Then I see the PHP-Defenders replying to some version of the above saying that is isn't necessarily true. I got to thinking "How is this possible...?" and "What counts as mixing presentation with logic?" I couldn't figure it out, so now I'm here.

Which of these is the best practice? Or is there an even better way that I'm not aware of?

<?php
if(!function()) {
echo '<div id="results">The result is a lie.</div>';
}
?>
Or
<div id="results">
<?php
if(!function()) {
echo 'The result is a lie.';
}
?>
</div>

I know the above examples don't really look like a big deal, but after browsing through web apps of mine, I realized it was all kind of messy (because I was mixing HTML and PHP), so I was hoping there was a good way to develop while keeping things nice and neat.

View 7 Replies View Related

Manage Business Contacts

We are 3 persons contacting various potential clients/customers and also
potential advertisers for our website.

Each person work at home, and it becomes ever difficult to manage our
contacts. Also we don't see what the others do.

Does it exist something allowing to manage such contacts. Ideally, this
should be put on a webserver, allowing each of us to build a client's
database, and the contacts history (like the program called ACT! on PC
www.act.com , but it's too expensive for what we do).

Ideally, we should be able to:
- create a new client (company, address, list of contact name and their
respective role in the company, phone/fax/mobile...)
- manage any contact with some details: name, date/time, comment, reminder
creation (please call back on monday...)
- a reminder, allowing to remind us when to call again, linked to a
checklist (first phone contact, second phone contact, visit, etc)
- a check list for any customer type.
- a calendar/user, allowing to know where the commercial is. This should
also allow us to know if they meet other companies or don't work at all,
since they are at home, we can't see if they really work or not.

Obviously, any item should be filled by any user, and there should be a
possibility to know who did any item. (who contacted the user, who filled
the address...).

The idea is to be able to fill the address when it's time to (evening,
week-ends) by an user, and then when the commercial connect to the page (or
even by email with a link) he knows he must contact the client.

View 3 Replies View Related

Checking For Previous Business Day

I am currently working on a timesheet application and need a way to check if a user has submitted time for the previous business day.

I believe i can use the mktime function to check for the previous day..however for the beginning of the week i would have to check for the previous friday. Can anyone help? i will also look at the mktime function more closely.

View 1 Replies View Related

Business Days B/w Two Dates

How do I count the no.of business days between two dates in php.

View 2 Replies View Related

CMS To Create A Business Directory?

I want to create a Private Business Directory website. Private in the sense, users need to login to view the directory. I am planning to use a CMS built in PHP. Which is the best PHP CMS to create a Business Directory?

View 1 Replies View Related

Calculating Business Days?

I am using this function (taken from php.net site) to calculate business days between two dates

PHP Code:

function getWorkingDays($startDate,$endDate,$holidays){
//The total number of days between the two dates. We compute the no. of seconds and divide it to 60*60*24
//We add one to inlude both dates in the interval.
$days = (strtotime($endDate) - strtotime($startDate)) / 86400 + 1;
$no_full_weeks = floor($days / 7);

[Code]....

View 2 Replies View Related

Create An Array Of Business Days?

I need a method for creating an array of "business days" in PHP beteewn 2 dates.

For example:

getWorkingDays("2008-01-01","2009-06-30");

Will create an array like the following:

Array
(
[0] ="2008-01-01",
[1] ="2008-01-05",
[2] ="2008-01-06",
[3] ="2008-01-07",

[Code]....

View 2 Replies View Related

Communicate With Dynamics AX Business Connector?

PROBLEM: I need to feed data from a PHP script into Dynamics AX. METHOD: I suppose the easiest way to do this is by using the Dynamics AX Business Connector. QUESTION: Is it possible to connect to the Dynamics AX Business Connector directly from a PHP script? If so: How?

View 2 Replies View Related

Java Business Rule Engine?

implemented in PHP ?If yes, please list them.f not, than why not, what are thereasons behind not having BusinessRule Engine in PHP and having it inJava ?

View 7 Replies View Related

Create A Business Directory Listing?

I'd a web designer only work with xhtml-css-jquery , I want to createa business listing website, whats the best way to get a clean result and able to edit in the future

View 8 Replies View Related

Business Best Practice On Validating Filename?

I have a "dilema" and wonder what is business best practice.I'm using Uploadify to upload images. Now I need to validate the filename before saving the file.I've looked at different solutions, but can't get down to one good solution.Here are my criterias:

Filename must be all in lowercase
Filename can only contain charaters [a-z0-9_-]
I must be able to rename file

How would you go about if a filename is my.file(name).jpeg ?I could explode the filename on '.' and save the extension, then implode to get the filename again. But not sure if that's the best soltion.I have the following functions that helps a bit:

function getExts($filename) \
[code]............

View 5 Replies View Related

Security At Yahoo Business Site

If I put a password on a folder at my yahoo business site, and also have a php login system of some type, will data be relatively secure, or will it be easy to hack? I am also looking for a good model for an html/php form to add/search/update records in mysql. I have been searching in google for several days, but cant seem to find the right thing.

View 5 Replies View Related

Use Zfdatagrid Library In Application / Tack Overflow Thread Zend Framework 1.10 Custom Class Inside Library Folder Not Found?

I am seeking to learn how to implement a grid in an application I am working on and I figured I will use zfdatagrid as it seems to take care of some of the features I need. However there is not much by way of tutorial on the net. Probably because its easy to figure out, but thing is I need help to understand how use it. I will appreaciate any link that can help or if one will be kind to give me some pointers here.

I now get the following error:

Fatal error: Class 'Bvb_Grid' not
found in
D:wwwlabzfdatagridapplicationcontrollersIndexController.php

and below is my indexAction
public function indexAction()
{
//Zend_Config
$config = new Zend_Config_Ini(getcwd().'..applicationgridsgrid.ini', 'production');
var_dump($config);
//Grid Initialization
$grid = Bvb_Grid::factory('Bvb_Grid_Deploy_Table', $config, 'id');
//Setting grid source
$grid->setSource(new Bvb_Grid_Source_Zend_Table(new Bugs()));
//CRUD Configuration
$form = new Bvb_Grid_Form();
$form->setAdd(true)->setEdit(true)->setDelete(true);
$grid->setForm($form);
//Pass it to the view
$this->view->pages = $grid;
$this->render('index');
}

The Bvb library is located in the Library folder.

Well silly me I found the solution to the problem in another Stack Overflow thread Zend Framework 1.10 custom Class inside library folder not found

I thought of deleting the question then I thought this may save someone following this thread a google.

View 1 Replies View Related

Is There A Feature-rich PHP CMS Stable Enough For A Business Site??

I know this probably has been ask time and time again. With all the PHP content mgt systems available, is there one that is feature rich like the PostNuke that is stable enough for a business site?

Or should I consider one in another language if there is one? Note: I'm not a programmer nor have the time to learn so I cannot write one myself as some may recommend!

View 3 Replies View Related

Sessions Not Working In Yahoo Small Business

I developed web app using Php and used sessions. Everything works on
my test server but sessions just dont work on the clients server which
uses Yahoo Small Business to host their site.

For example:
<?php
session_start();
if (!$_SESSION['count']) {
echo "Not registered<BR>";
$_SESSION['count'] = 1;
$count = 1;
} else {
$count = $_SESSION['count']++;
}
echo "count is '$count'";
?>

Always shows count as 1.

The yahoo site uses PHP Version 4.3.6.
The only difference relevant I can see in the two sites is
session.use_trans_sid which is off on Yahoo. Enabling this with ini_set
didnt help. Saving session information in the DB using custome session
handlers didnt help either.
Any ideas as to why this may be happenning?

Other relevant php info is pasted below:

Session Support enabled
Registered save handlers files user

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

View 4 Replies View Related

Make Business Card With Fpdf Or Tcpdf Or Others?

I have a jpg image for the business card layout with dimensions: 9,8 cm/5,9 cm. I have to put it as background layout and on top of this layout i have to print name/address/telephone number email etc. And print it/save it as pdf for later use.

But problem is i cant make it work with FPDF or TCPDF. Any idea how can i prepare this? with FPDF or TCPDF?

View 2 Replies View Related

Mvc - Codeigniter - Use Models When There Is Very Little Business Login In A Controller?

I am using codeigniter framework. Most of the modules are very simple and they just have select * from table and a pagination. so the Index() function would have just three lines of code. In this case what is the purpose of including model in the structure. Do we have to use models compulsory to maintain standard or can we exclude according to the simplicity of the total business login in that module???

Some times i need to fetch data from three tables other than the main iteration. and i am replicating this in three function in one controller. Hope for this i can use models. I would like to have suggestions and comments on this.

View 2 Replies View Related

Getting A Parsing Error With Geocoding Business Locator?

I have been working on this thing for 2 weeks, and I continue to get errors. I was getting errors with my line 2 require code, but I think I fixed that, now only to get a parsing code: (Parse error: syntax error, unexpected '(' in / home / massage / public_html / phpsqlsearch_genxml.php on line 14)I have the reset of the code I will try to attach it,, I am somewhat okay with php and phpmyadmin, but not very strong. I am trying to build the map at http:[url].....

View 12 Replies View Related

Enforcing Referential Integrity With Business Objects

I am working on a mysql application to perform basic inventory management in a warehouse/production setting. Question: I have a table of parts with many tables in my database linked to this table. If the part exists anywhere else in the database I don't want it deleted. For this application I am going with a Business-Objects approach. I am using classes to represent each part. What would be the best way to enforce this kind of referential integrity in my business object (or maybe outside of business object) with there being so many tables tied to this table? Here are some of the choices I have come up with:

1) Let the database handle it for me and use the database exception to tell the user something like: "Can't delete this part or make this change because of [insert reason]" Reasons I like this: seems easy, simpler to handle concurrency problems Reasons I don't like this: 1) seems to go against good app design

2) I would like to be able to list reasons to the user indicating specific reasons why a deletion is not allowed ("Part is in current inventory and Bill of materials"). I'm not sure if this method would allow me to do so.

3) Query every table (possibly a stored procedure) that is linked to the part to see if there is any referential integrity issues- keep the results as properties of my class. Reasons I like this: 1) It would be nice to have this in with the class so that Reasons I do not like this: 1) The query would probably become expensive as the database grows.

4) Some kind of transaction scheme where when the part is used by one of the tables then a transaction occurs. I'm thinking of a table like this: (partID, table, IO_Code) where the IO_Code would be a positive or negative one depending on whether the part is being used somewhere in the database. If the sum of the IO_Codes is zero then the part is OK to delete, the tables using the query could use be found easily using the same table. Reasons I like this: Doesn't seem that complex, I'm thinking I could use triggers in the various tables to write to the transactions table.

View 4 Replies View Related

Invalid Library (maybe Not A PHP Library) 'libmysql.dll' PHP5

WinXP Pro, Apache 1.3.27, trying to add PHP 5.0.4 with MySQL support to
the mix. Everything works fine until I add 'extension=libmysql.dll' to
php.ini, and then starting Apache gives me the same error popup two or
three times, all with the same message:

PHP Startup: Invalid library (maybe not a PHP library) 'libmysql.dll'

I've tried all manner of variations of extension_dir, and copied
libmysql.dll from the php5 distro into c:windowssystem32, all to no
avail. PHP seems to work otherwise, but there's no MySQL support.

View 6 Replies View Related

Python - PostgreSQL Design Suitable For A Business Application?

I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are problems with this approach, if I am targeting the wrong tools, etc.

I'm looking at PHP because it is widely used, fairly mature, and I can find ample people with skills in PHP interface design. I'm looking at Python because of the benefits of readable code, because I hear can find more Python programmers that also have subject-matter skills (in this case, finance), and it's an open source language. Plus, it seems easier to code with. I'm looking at PostgreSQL for the transaction-level features. MySQL is also an option here, but I don't need to debate this aspect.

This is not a web application, although I would like to utilize a browser for the user interface. This is more of an Enterprise Application, but for a small business with moderate numbers of users (maybe 5-10) and a modest number of daily transactions. What is important is that we are able to upgrade the database or domain logic or interface separate from the other layers in the future.

View 7 Replies View Related

Separate DAL From Business Layer - Anemic Domain Model

I was trying to separate my DAL from my Business Layer, and in doing so, I decided to eschew any ActiveRecord approach and go for a DataMapper approach. In other words, my domain objects would not take care of persisting themselves. In doing so, I seem to be encroaching on the "anemic domain model" anti-pattern. For instance, one of the entities in my program is an Organization. An organization is represented as something like this:

class Organization {
private $orgId;
private $orgName;
// getters and setters
}

So basically this organization does nothing other than act as "bag" (as Martin Fowler says) for some data. In the PHP world it is nothing more than a glorified array. There is zero behaviour associated with it. And behaviour in the program, I've been sticking in "service level" class like an OrganizationService which mostly serves as an intermediary between these objects and the DAL. Other than potential scaling issues with PHP (I do have other reasons why I insist on "bagging" my data in these objects), is this approach totally off? How do you handle your domain models in these situations? Perhaps an organization isn't part of my domain in the first place?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved