Hi! I'm doing a project using OpenStreetMap and OpenLayers. Currently, my task is to insert the data from the OSM file that I have to a PostgreSQL. When I checked out Osmosis (the tool for transferring data from the OSM file to the database), it says there that, in one example, "Import a planet file into a local PostgreSQL rails port database.". Does it mean that I have to use Ruby on Rails for my project? I don't know Rails and learning it will take too much of my time. Can I jsut use PHP to access the database? Please help me. Thanks a lot!
You need to know that the interface/application you see when opening www.openstreetmap.org is written in RoR. The API for the access of the data - the geo coding - is done via a PHP API. So you do not need Rails if you are not planning on using it. The database doesn't care.
By the way, an alternative to Osmosis is osm2pgsql that doesn't "say" anything about a Rails dependency (that is, as said before, not used anyway).
You can import the node,ways,tags etc into a database schema like the one used for on the OpenStreetMap servers. The Ruby on Rails migrations are ultimately the one true source for the latest schema used by the OSM servers. But you'd probably want to create a database with a similar schema using the database creation scripts bundled with the Osmosis distribution within the script/contrib directory.
Alternatively, for some applications you might want to PostGIS enable your Postgres database (load in a load of geospatial functions and data types) and then load in OpenStreetMap data in a format which makes use of these types. You can do that with Osmosis, or osm2pgsql. See PostGIS
Alternatively for more basic applications you might look at parsing the .osm format for yourself. An osm file contains some "node" and "way" elements. Each of these can have have several "tag" elements. There's "relation" elements too. These can can be unnecessary for many applications, but it all depends what you want to do. Maybe you only need nodes (for POI data applications) For some work it may be viable to work directly with a .osm file, parsed within PHP with no database involved, although generally not for for any meaningfully large area of map data.
You may find some useful code scattered around among the tools listed at Category:PHP