Jump to content

Zyx

Members
  • Posts

    129
  • Joined

  • Last visited

About Zyx

  • Birthday 03/10/1988

Contact Methods

  • Website URL
    http://techvival.zyxist.com/

Profile Information

  • Gender
    Male
  • Location
    Poland

Zyx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Both nginx and Symfony produce logs: nginx: /var/log/nginx/ Symfony: [your project directory]/var/logs/dev.log or prod.log If you're able to run the default page, I think that Nginx works, and the problem is on the framework side. Routing problems are generally reported in Symfony log files and they should give you some clue. For development purpose, use app_dev.php file instead of app.php. In the development mode, Symfony shows detailed information about exceptions directly in the browser, and you have an access to the profiler, too.
  2. Moreover, extracting variables from arrays fetched from external sources poses a threat to the security of the application. What if someone puts a key into an array that overwrites an existing variable belonging to your application? You can repack it to use it more conveniently, but always keep these data in some array or object. $json_ary = json_decode($file, true); $weatherInfo = array( 'temperature' => $json_ary['properties']['temperature']['value'], ); echo $weatherInfo['temperature'];
  3. Many general-purpose frameworks are in fact optimized for relatively simple CRUD applications. Claiming that a single, hard-coded approach is good for every kind of application is a nonsense. Of course, it is possible to write many different kinds of applications with almost every framework, but possible does not mean that it is well-designed. The problem is that many programmers have no idea about software architectures and they simply don't know that they could solve their problems much easier just by picking a different architecture. The outgrowing problem has the following reasons: - the programmer discovers that he or she has difficulties in writing non-trivial applications, - performance reasons - the framework is not able to handle big traffic or has problems with scalability (i.e. because of the invalid caching) - it is very hard to integrate the framework with third party tools, - the programmer does not agree with some of the design concepts. I know many programmers who decided not to use frameworks, just because they forced them to use Object-Relational Mapping. Many frameworks have a big fanbase, because most of the programmers actually write relatively simple CRUD applications, and they have the tool that perfectly suits their needs. The last thing: being tied to a single framework is not a good thing for programmer, too, especially that the general idea of web frameworks in PHP follows the same architecture and the differences are not too big. You know one, you know all of them.
  4. You haven't precised, what area of telecom you are interested in, but for the telecommunications middleware, Erlang is often chosen. It has a certain benefit over C/C++/Java: a usable, predictable, and scalable concurrency model.
  5. It's an architectural pattern, or - in other words - a well-tested recipe, how to organize the structure of your application in order to get certain benefits. You can implement it yourself, or use an application framework that does it for you. If you do not know what design and architectural patterns are, you should try to learn something about object-oriented programming and object-oriented design. MVC is an ancestor of the whole family of patterns. In the webdevelopment circles, most articles claiming they describe MVC, actually describe one of its distant descendants.
  6. Singletons are evil. Registries are evil. Global variables are evil. Static class variables are evil. Do not use them. EVER. Why? They introduce a global state which is hard to track, hard to test and hard to debug. Once your application gets bigger, you will get lost in the number of dependencies and the way the application works. Every change in component A will destroy component B without no visible reason. If you want to improve it, take a look at the dependency injection container pattern, and the dependency injection idea itself. You do not even have to implement it on your own, because there are existing, standalone implementations, such as the Symfony 2 Dependency Injection Component ( http://components.symfony-project.org )
  7. The topic was discussed several times already: http://www.phpfreaks.com/forums/application-frameworks/the-yii-framework/ http://www.phpfreaks.com/forums/application-frameworks/anyone-tried-yii/ And I'll never understand people who still use CodeIgniter... it's like writing websites under DOS in 2010. Have you seen Kohana?
  8. Yes, these are the boundary cases. In the if that splits the columns, you must put each tag in one more if: if(! its_the_first_element) { echo '</div>'; } if(! its_the_last_element) { echo '<div ... >'; } You can use the counter to test, whether it is the first or the last element. In addition, to recognize the last element, you must take the total number of results with mysql_num_rows().
  9. I haven't heard of such a language, but if there exists any, I'd rather say that you should not look at indoeuropean languages. However, in some languages both forms are commonly used. Polish: "Krok pierwszy", "Krok 1" In other, the word order is different. Slovak: "PrvĂ˝ krok", "1. krok"
  10. Programming is not everything. How about application design, requirement analysis? These are more challenging jobs, and often - better paid. I find building ordinary websites a bit boring too, but on the other hand, I really enjoy designing tools for building them. You could also check it out.
  11. Which database system? For MySQL, you have the following construct: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
  12. Is this array statically or dynamically allocated? Multidimensional, contignuous arrays are in fact one-dimensional arrays with a more complex index calculation and this is how I always implement them: int *array = (int*) malloc(sizeof(int) * size_x * size_y); array[x + y * size_y] = 13; You can write a macro to wrap it and use more easily. String types are also pretty simple: // allocate array memory char **array = (char**) malloc(sizeof(char*) * size_x * size_y); // allocate string memory array[x + y * size_y] = (char*) malloc(sizeof(char) * 30); // write something to the string array[x + y * size_y][2] = 'z'; It will allocate an array of pointers to string arrays.
  13. Hmmm... wait, I read wrong. You want to put it into columns vertically, not horizontally. However, it's also a simple mathematics. You must count the total number of elements you want to display, divide it by three to estimate, how many you will get within a single column. Then you apply the modulo division every time you display an element: $counter = 0; foreach($elements as $element) { if($counter % $elementNumInAColumn == 0) { echo '</div><div>'; } // display the element here. $counter++; } Boundary cases are boundary cases: the first and the last element. Run the script above, and see what's happening with the tags before the first and after the last element. This is because the script does not handle the boundary cases correctly. I leave it to you as an exercise. You have all the necessary information you need: you know when you reach the first element, and when you reach the last. Make use of this knowledge. PS. Do you really have no clue what modulo division is and how it works?
  14. Use the modulo division. It's a simple mathematics: if($counter % 3 == 0) { // break } You just have to remember about the boundary cases.
  15. The code in the tutorial does not show any MVC. It's just a piece of code, where some parts were given the names of "model", "view" and "controller" without any noticeable sense and understanding what they actually mean. Remember that naming something "observer" and "observable" does not give us the Observer pattern, if we do not implement the correct interactions between them. The same is with MVC. Most of the current PHP frameworks (and Ruby on Rails that started the game) do not actually implement MVC, but one of its many derivatives, i.e. Model-View-Presenter with Passive View. I was working with MVC for a while, and believe me (or look for the original pattern definitions and check it yourself) - this is a completely different world from what we see. In addition, if you want to learn OOP, I would throw away the outdated CodeIgniter code. I even wonder why people are still using this framework, if there are plenty of much better alternatives. Take a look at Symfony 2, which aims to set a completely new quality among the frameworks: https://github.com/symfony/symfony . You can also look at my experimental framework, where I make MVC experiments: https://github.com/zyxist/Trinity . First of all, try to understand the concepts behind them, and their structure. Writing a framework is not easy, at least if you want it to be usable .
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.